From d5f9b5df613ef9ed2e81bd2fb495e482fc20a979 Mon Sep 17 00:00:00 2001 From: Patrick Cartlidge Date: Tue, 19 Nov 2024 11:06:55 +0000 Subject: [PATCH] config update --- .../src/govuk/common/configuration.mjs | 2 +- ...tend-component-configurable.jsdom.test.mjs | 33 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/packages/govuk-frontend/src/govuk/common/configuration.mjs b/packages/govuk-frontend/src/govuk/common/configuration.mjs index 537753ecb3..63947cd1f6 100644 --- a/packages/govuk-frontend/src/govuk/common/configuration.mjs +++ b/packages/govuk-frontend/src/govuk/common/configuration.mjs @@ -15,7 +15,7 @@ export const configOverride = Symbol.for('configOverride') * @template {Element & { dataset: DOMStringMap }} [RootElementType=HTMLElement] * @augments Component */ -export class GOVUKFrontendComponentConfigurable extends Component { +export class ConfigurableComponent extends Component { /** * configOverride * diff --git a/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs b/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs index 5e1f4831c3..83326e32cc 100644 --- a/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs +++ b/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs @@ -1,8 +1,5 @@ import { ConfigError } from '../../errors/index.mjs' -import { - GOVUKFrontendComponentConfigurable, - configOverride -} from '../configuration.mjs' +import { ConfigurableComponent, configOverride } from '../configuration.mjs' describe('GOVUKFrontendComponentConfigurable', () => { beforeEach(() => { @@ -18,7 +15,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { describe('throws error', () => { it('if no schema defined', () => { - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static defaults = { @@ -26,7 +23,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { } } - expect(() => new ConfigurableComponent(document.body)).toThrow( + expect(() => new MockConfigurableComponent(document.body)).toThrow( new ConfigError( 'config-component: Config passed as parameter into constructor but no schema defined' ) @@ -34,7 +31,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { }) it('if no defaults defined', () => { - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -44,7 +41,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { } } - expect(() => new ConfigurableComponent(document.body)).toThrow( + expect(() => new MockConfigurableComponent(document.body)).toThrow( new ConfigError( 'config-component: Config passed as parameter into constructor but no defaults defined' ) @@ -58,7 +55,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -74,7 +71,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent) + const configComponent = new MockConfigurableComponent(testComponent) expect(configComponent._config).toMatchObject({ randomAttribute: 0 }) }) @@ -84,7 +81,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -100,7 +97,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent) + const configComponent = new MockConfigurableComponent(testComponent) expect(configComponent._config).toMatchObject({ randomAttribute: 42 }) }) @@ -110,7 +107,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -126,7 +123,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent, { + const configComponent = new MockConfigurableComponent(testComponent, { randomAttribute: 100 }) @@ -138,7 +135,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -154,7 +151,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent, { + const configComponent = new MockConfigurableComponent(testComponent, { randomAttribute: 100 }) @@ -170,7 +167,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { [configOverride](config) { return configOverrideFunction(config) } @@ -190,7 +187,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent, { + const configComponent = new MockConfigurableComponent(testComponent, { randomAttribute: '14' })