-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making sure to kebab case CSS variables generated from presets, so `h…
…1` will become `h-1` (#44406) Adding test coverage
- Loading branch information
1 parent
a5ca42a
commit 144a47b
Showing
4 changed files
with
51 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { upperFirst } from '../styles/utils'; | ||
import { | ||
camelCaseJoin, | ||
getCSSVarFromStyleValue, | ||
upperFirst, | ||
} from '../styles/utils'; | ||
|
||
describe( 'utils', () => { | ||
describe( 'upperFirst()', () => { | ||
it( 'should return an string with a capitalized first letter', () => { | ||
expect( upperFirst( 'toontown' ) ).toEqual( 'Toontown' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'camelCaseJoin()', () => { | ||
it( 'should return a camelCase string', () => { | ||
expect( camelCaseJoin( [ 'toon', 'town' ] ) ).toEqual( 'toonTown' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'getCSSVarFromStyleValue()', () => { | ||
it( 'should return a compiled CSS var', () => { | ||
expect( | ||
getCSSVarFromStyleValue( 'var:preset|color|yellow-bun' ) | ||
).toEqual( 'var(--wp--preset--color--yellow-bun)' ); | ||
} ); | ||
|
||
it( 'should kebab case numbers', () => { | ||
expect( | ||
getCSSVarFromStyleValue( 'var:preset|font-size|h1' ) | ||
).toEqual( 'var(--wp--preset--font-size--h-1)' ); | ||
} ); | ||
|
||
it( 'should kebab case camel case', () => { | ||
expect( | ||
getCSSVarFromStyleValue( 'var:preset|color|heavenlyBlue' ) | ||
).toEqual( 'var(--wp--preset--color--heavenly-blue)' ); | ||
} ); | ||
} ); | ||
} ); |