-
Notifications
You must be signed in to change notification settings - Fork 571
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 410e710
Showing
3 changed files
with
126 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 |
119 changes: 119 additions & 0 deletions
119
__tests__/common/templates/css/fonts.css.template.test.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,119 @@ | ||
import { expect } from 'chai'; | ||
import cssFontsTemplate from '../../../../lib/common/templates/css/fonts.css.template.js'; | ||
|
||
describe('common', () => { | ||
describe('templates', () => { | ||
describe('css', () => { | ||
describe('fonts.css.template', () => { | ||
it('should produce a valid css font-face declaration without weight or style defined', () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
expect(output).to.equal(`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
}`); | ||
}); | ||
it('should produce a valid css font-face declaration with a weight defined', () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
weight: { | ||
value: 400, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
expect(output).to.equal(`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
font-weight: 400; | ||
}`); | ||
}); | ||
it('should produce a valid css font-face declaration with a style defined', () => { | ||
const tokens = { | ||
asset: { | ||
font: { | ||
myFont: { | ||
name: { | ||
value: 'font', | ||
type: 'fontFamily', | ||
}, | ||
ttf: { | ||
value: 'font.ttf', | ||
type: 'asset', | ||
}, | ||
style: { | ||
value: 'normal', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const output = cssFontsTemplate(tokens); | ||
expect(output).to.equal(`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
font-style: normal; | ||
}`); | ||
}); | ||
it('should produce a valid css font-face declaration with both style and weight defined', () => { | ||
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); | ||
expect(output).to.equal(`@font-face { | ||
font-family: "font"; | ||
src: url('../font.ttf') format('truetype'); | ||
font-style: normal; | ||
font-weight: 400; | ||
}`); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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