Skip to content

Commit

Permalink
config update
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpatrickpatrick committed Nov 19, 2024
1 parent 3611a73 commit d5f9b5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/govuk-frontend/src/govuk/common/configuration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const configOverride = Symbol.for('configOverride')
* @template {Element & { dataset: DOMStringMap }} [RootElementType=HTMLElement]
* @augments Component<RootElementType>
*/
export class GOVUKFrontendComponentConfigurable extends Component {
export class ConfigurableComponent extends Component {
/**
* configOverride
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand All @@ -18,23 +15,23 @@ describe('GOVUKFrontendComponentConfigurable', () => {

describe('throws error', () => {
it('if no schema defined', () => {
class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
static moduleName = 'config-component'

static defaults = {
randomAttribute: 0
}
}

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'
)
)
})

it('if no defaults defined', () => {
class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
static moduleName = 'config-component'

static schema = {
Expand All @@ -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'
)
Expand All @@ -58,7 +55,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
<div id="test-component"></div>
`

class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
static moduleName = 'config-component'

static schema = {
Expand All @@ -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 })
})
Expand All @@ -84,7 +81,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
<div id="test-component" data-random-attribute="42"></div>
`

class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
static moduleName = 'config-component'

static schema = {
Expand All @@ -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 })
})
Expand All @@ -110,7 +107,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
<div id="test-component"></div>
`

class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
static moduleName = 'config-component'

static schema = {
Expand All @@ -126,7 +123,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {

const testComponent = document.querySelector('#test-component')

const configComponent = new ConfigurableComponent(testComponent, {
const configComponent = new MockConfigurableComponent(testComponent, {
randomAttribute: 100
})

Expand All @@ -138,7 +135,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
<div id="test-component" data-random-attribute="12"></div>
`

class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
static moduleName = 'config-component'

static schema = {
Expand All @@ -154,7 +151,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {

const testComponent = document.querySelector('#test-component')

const configComponent = new ConfigurableComponent(testComponent, {
const configComponent = new MockConfigurableComponent(testComponent, {
randomAttribute: 100
})

Expand All @@ -170,7 +167,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
<div id="test-component" data-random-attribute="13"></div>
`

class ConfigurableComponent extends GOVUKFrontendComponentConfigurable {
class MockConfigurableComponent extends ConfigurableComponent {
[configOverride](config) {
return configOverrideFunction(config)
}
Expand All @@ -190,7 +187,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {

const testComponent = document.querySelector('#test-component')

const configComponent = new ConfigurableComponent(testComponent, {
const configComponent = new MockConfigurableComponent(testComponent, {
randomAttribute: '14'
})

Expand Down

0 comments on commit d5f9b5d

Please sign in to comment.