diff --git a/src/props.easing.css b/src/props.easing.css index d0d03626..9e90ebb8 100644 --- a/src/props.easing.css +++ b/src/props.easing.css @@ -44,11 +44,11 @@ --ease-elastic-3: var(--ease-elastic-out-3); --ease-elastic-4: var(--ease-elastic-out-4); --ease-elastic-5: var(--ease-elastic-out-5); - --ease-squish-1: var(--elastic-in-out-1); - --ease-squish-2: var(--elastic-in-out-2); - --ease-squish-3: var(--elastic-in-out-3); - --ease-squish-4: var(--elastic-in-out-4); - --ease-squish-5: var(--elastic-in-out-5); + --ease-squish-1: var(--ease-elastic-in-out-1); + --ease-squish-2: var(--ease-elastic-in-out-2); + --ease-squish-3: var(--ease-elastic-in-out-3); + --ease-squish-4: var(--ease-elastic-in-out-4); + --ease-squish-5: var(--ease-elastic-in-out-5); --ease-spring-1: linear( 0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, diff --git a/src/props.easing.js b/src/props.easing.js index bb583ec9..bfaf0e0f 100644 --- a/src/props.easing.js +++ b/src/props.easing.js @@ -53,11 +53,11 @@ export default { '--ease-elastic-4': 'var(--ease-elastic-out-4)', '--ease-elastic-5': 'var(--ease-elastic-out-5)', - '--ease-squish-1': 'var(--elastic-in-out-1)', - '--ease-squish-2': 'var(--elastic-in-out-2)', - '--ease-squish-3': 'var(--elastic-in-out-3)', - '--ease-squish-4': 'var(--elastic-in-out-4)', - '--ease-squish-5': 'var(--elastic-in-out-5)', + '--ease-squish-1': 'var(--ease-elastic-in-out-1)', + '--ease-squish-2': 'var(--ease-elastic-in-out-2)', + '--ease-squish-3': 'var(--ease-elastic-in-out-3)', + '--ease-squish-4': 'var(--ease-elastic-in-out-4)', + '--ease-squish-5': 'var(--ease-elastic-in-out-5)', '--ease-spring-1': `linear( 0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, diff --git a/test/basic.test.cjs b/test/basic.test.cjs index 917fe983..4719fb34 100644 --- a/test/basic.test.cjs +++ b/test/basic.test.cjs @@ -56,4 +56,55 @@ test('Should produce optional mask props', async t => { test('Should produce typings files', async t => { t.assert(fs.existsSync('./dist/open-props.module.d.ts')) t.assert(fs.existsSync('./src/props.sizes.d.ts')) +}) + +test('References should be valid', async t => { + const formatter = new Intl.ListFormat(); + const defined = new Set(); + const referenced = new Set(); + const referencedBy = new Map(); + + for (const [prop, value] of Object.entries(OpenProps)) { + // Add all defined variables to the defined set + defined.add(prop) + + if (typeof value !== 'string') { + continue; + } + + // Find all references to other variables: var(...) + const matches = value.matchAll(/var\(([^)]+)\)/g); + + if (!matches) { + continue; + } + + // Add all references to the referenced set + // Map all references to the prop that references them + for (const matchArray of matches) { + const reference = matchArray[1]; + + referenced.add(reference); + + if (!prop.startsWith('--')) { + continue; + } + + if (!referencedBy.has(reference)) { + referencedBy.set(reference, new Set()); + } + + referencedBy.get(reference).add(prop); + } + } + + // Check that all referenced variables are defined + for (const reference of referenced) { + const referencing = formatter.format(Array.from(referencedBy.get(reference))); + + t.assert( + defined.has(reference), + `Variable with name ${reference} was referenced by variable ${referencing}, but is not defined` + ); + } }) \ No newline at end of file