diff --git a/src/govuk/core/_global-styles.scss b/src/govuk/core/_global-styles.scss index 41ccc65da1..0131eee1dd 100644 --- a/src/govuk/core/_global-styles.scss +++ b/src/govuk/core/_global-styles.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the core layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @import "links"; diff --git a/src/govuk/core/_links.scss b/src/govuk/core/_links.scss index c6da949f11..b1d31a364e 100644 --- a/src/govuk/core/_links.scss +++ b/src/govuk/core/_links.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the core layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/core/links") { diff --git a/src/govuk/core/_lists.scss b/src/govuk/core/_lists.scss index 0a92fe2125..bfd215e95e 100644 --- a/src/govuk/core/_lists.scss +++ b/src/govuk/core/_lists.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the core layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/core/lists") { diff --git a/src/govuk/core/_section-break.scss b/src/govuk/core/_section-break.scss index 20b4fac24a..7104e1818e 100644 --- a/src/govuk/core/_section-break.scss +++ b/src/govuk/core/_section-break.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the core layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/core/section-break") { diff --git a/src/govuk/core/_template.scss b/src/govuk/core/_template.scss index f2e7b91345..1c003a8f22 100644 --- a/src/govuk/core/_template.scss +++ b/src/govuk/core/_template.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the core layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/core/template") { diff --git a/src/govuk/core/_typography.scss b/src/govuk/core/_typography.scss index e47ccf5cda..ad56961b9f 100644 --- a/src/govuk/core/_typography.scss +++ b/src/govuk/core/_typography.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the core layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/core/typography") { diff --git a/src/govuk/core/core.test.js b/src/govuk/core/core.test.js index 686686ef3e..4f5892f1d5 100644 --- a/src/govuk/core/core.test.js +++ b/src/govuk/core/core.test.js @@ -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 overrides layer without first importing ' + + '`base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0.' + ) + }) }) diff --git a/src/govuk/overrides/_display.scss b/src/govuk/overrides/_display.scss index 39ff5ba508..24b3137a14 100644 --- a/src/govuk/overrides/_display.scss +++ b/src/govuk/overrides/_display.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the overrides layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/overrides/display") { diff --git a/src/govuk/overrides/_spacing.scss b/src/govuk/overrides/_spacing.scss index ebe195caa2..7f54fe0244 100644 --- a/src/govuk/overrides/_spacing.scss +++ b/src/govuk/overrides/_spacing.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the overrides layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; //// diff --git a/src/govuk/overrides/_typography.scss b/src/govuk/overrides/_typography.scss index fb12379d3f..9541f308a7 100644 --- a/src/govuk/overrides/_typography.scss +++ b/src/govuk/overrides/_typography.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the overrides layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/overrides/typography") { diff --git a/src/govuk/overrides/_width.scss b/src/govuk/overrides/_width.scss index 671b6c3534..2993d38970 100644 --- a/src/govuk/overrides/_width.scss +++ b/src/govuk/overrides/_width.scss @@ -1,3 +1,7 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the overrides layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + @import "../base"; @include govuk-exports("govuk/overrides/width") { diff --git a/src/govuk/overrides/overrides.test.js b/src/govuk/overrides/overrides.test.js index 879f86a386..d83d68d3fe 100644 --- a/src/govuk/overrides/overrides.test.js +++ b/src/govuk/overrides/overrides.test.js @@ -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.' + ) + }) })