-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for font.css.template changes
- Loading branch information
1 parent
ae4b8d5
commit 27583c1
Showing
4 changed files
with
144 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'style-dictionary': patch | ||
--- | ||
|
||
Fix font-style and font-weight logic for fonts.css.template.js |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* @web/test-runner snapshot v1 */ | ||
export const snapshots = {}; | ||
|
||
snapshots["formats fonts/css should produce a valid css font-face declaration without weight or style defined"] = | ||
`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
}`; | ||
/* end snapshot formats fonts/css should produce a valid css font-face declaration without weight or style defined */ | ||
|
||
snapshots["formats fonts/css should produce a valid css font-face declaration with a weight defined"] = | ||
`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
font-weight: 400; | ||
}`; | ||
/* end snapshot formats fonts/css should produce a valid css font-face declaration with a weight defined */ | ||
|
||
snapshots["formats fonts/css should produce a valid css font-face declaration with a style defined"] = | ||
`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
font-style: normal; | ||
}`; | ||
/* end snapshot formats fonts/css should produce a valid css font-face declaration with a style defined */ | ||
|
||
snapshots["formats fonts/css should produce a valid css font-face declaration with both style and weight defined"] = | ||
`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
font-style: normal; | ||
font-weight: 400; | ||
}`; | ||
/* end snapshot formats fonts/css should produce a valid css font-face declaration with both style and weight defined */ | ||
|
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { expect } from 'chai'; | ||
import cssFontsTemplate from '../../lib/common/templates/css/fonts.css.template.js'; | ||
|
||
describe('formats', () => { | ||
describe('fonts/css', () => { | ||
it('should produce a valid css font-face declaration without weight or style defined', async () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
await expect(output).to.matchSnapshot(); | ||
}); | ||
|
||
it('should produce a valid css font-face declaration with a weight defined', async () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
weight: { | ||
value: 400, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
await expect(output).to.matchSnapshot(); | ||
}); | ||
|
||
it('should produce a valid css font-face declaration with a style defined', async () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
style: { | ||
value: 'normal', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
await expect(output).to.matchSnapshot(); | ||
}); | ||
|
||
it('should produce a valid css font-face declaration with both style and weight defined', async () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
style: { | ||
value: 'normal', | ||
}, | ||
weight: { | ||
value: 400, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
await expect(output).to.matchSnapshot(); | ||
}); | ||
}); | ||
}); |
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