-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1807 from alphagov/warn-import-core-overrides-wit…
…hout-dependencies Warn if importing core, overrides w/o dependencies
- Loading branch information
Showing
12 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
/* eslint-env jest */ | ||
|
||
const sass = require('node-sass') | ||
|
||
const glob = require('glob') | ||
const { renderSass } = require('../../../lib/jest-helpers') | ||
const configPaths = require('../../../config/paths.json') | ||
|
||
const sassFiles = glob.sync(`${configPaths.src}/core/**/*.scss`) | ||
|
||
it.each(sassFiles)('%s renders to CSS without errors', (file) => { | ||
return renderSass({ file: file }) | ||
it.each(sassFiles)('%s renders with a deprecation warning', (file) => { | ||
// Create a mock warn function that we can use to override the native @warn | ||
// function, that we can make assertions about post-render. | ||
const mockWarnFunction = jest.fn() | ||
.mockReturnValue(sass.NULL) | ||
|
||
return renderSass({ | ||
file: file, | ||
functions: { | ||
'@warn': mockWarnFunction | ||
} | ||
}).then(() => { | ||
// Expect our mocked @warn function to have been called once with a single | ||
// argument, which should be the deprecation notice | ||
return expect(mockWarnFunction.mock.calls[0][0].getValue()) | ||
.toEqual( | ||
'Importing items from the core layer without first importing `base` ' + | ||
'is deprecated, and will no longer work as of GOV.UK Frontend v4.0.' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
/* eslint-env jest */ | ||
|
||
const sass = require('node-sass') | ||
|
||
const glob = require('glob') | ||
const { renderSass } = require('../../../lib/jest-helpers') | ||
const configPaths = require('../../../config/paths.json') | ||
|
||
const sassFiles = glob.sync(`${configPaths.src}/overrides/**/*.scss`) | ||
|
||
it.each(sassFiles)('%s renders to CSS without errors', (file) => { | ||
return renderSass({ file: file }) | ||
it.each(sassFiles)('%s renders with a deprecation warning', (file) => { | ||
// Create a mock warn function that we can use to override the native @warn | ||
// function, that we can make assertions about post-render. | ||
const mockWarnFunction = jest.fn() | ||
.mockReturnValue(sass.NULL) | ||
|
||
return renderSass({ | ||
file: file, | ||
functions: { | ||
'@warn': mockWarnFunction | ||
} | ||
}).then(() => { | ||
// Expect our mocked @warn function to have been called once with a single | ||
// argument, which should be the deprecation notice | ||
return expect(mockWarnFunction.mock.calls[0][0].getValue()) | ||
.toEqual( | ||
'Importing items from the overrides layer without first importing ' + | ||
'`base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0.' | ||
) | ||
}) | ||
}) |