fix: restore Theme 2 font families
This commit is contained in:
parent
9e4592df59
commit
341b1c1c3e
5 changed files with 75 additions and 2 deletions
24
test/unit/specs/services/style_setter/style_setter.spec.js
Normal file
24
test/unit/specs/services/style_setter/style_setter.spec.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { hasInvalidCachedThemeRules } from 'src/services/style_setter/style_setter.js'
|
||||
|
||||
describe('style setter cache', () => {
|
||||
it('rejects cached rules containing serialized objects', () => {
|
||||
expect(
|
||||
hasInvalidCachedThemeRules([
|
||||
['html { --font: [object Object]; }'],
|
||||
['.post { --font: sans-serif; }'],
|
||||
]),
|
||||
).to.equal(true)
|
||||
})
|
||||
|
||||
it('accepts cached rules containing valid font families', () => {
|
||||
expect(
|
||||
hasInvalidCachedThemeRules([
|
||||
['html { --font: sans-serif; }'],
|
||||
[
|
||||
'.post { --font: "Atkinson Hyperlegible"; }',
|
||||
'.post::after { content: "[object Object]"; }',
|
||||
],
|
||||
]),
|
||||
).to.equal(false)
|
||||
})
|
||||
})
|
||||
42
test/unit/specs/services/theme_data/theme2_to_theme3.spec.js
Normal file
42
test/unit/specs/services/theme_data/theme2_to_theme3.spec.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import {
|
||||
basePaletteKeys,
|
||||
convertTheme2To3,
|
||||
} from 'src/services/theme_data/theme2_to_theme3.js'
|
||||
|
||||
describe('Theme 2 to Theme 3 conversion', () => {
|
||||
it('converts font descriptors to CSS font families', () => {
|
||||
const colors = Object.fromEntries(
|
||||
[...basePaletteKeys].map((key) => [key, '#000000']),
|
||||
)
|
||||
const rules = convertTheme2To3({
|
||||
colors,
|
||||
fonts: {
|
||||
interface: { family: 'sans-serif' },
|
||||
input: { family: 'Open Sans' },
|
||||
post: { family: 'Atkinson Hyperlegible' },
|
||||
postCode: { family: 'monospace' },
|
||||
},
|
||||
})
|
||||
|
||||
expect(rules).to.deep.include({
|
||||
source: '2to3',
|
||||
component: 'Root',
|
||||
directives: { '--font': 'generic | sans-serif' },
|
||||
})
|
||||
expect(rules).to.deep.include({
|
||||
source: '2to3',
|
||||
component: 'Root',
|
||||
directives: { '--monoFont': 'generic | monospace' },
|
||||
})
|
||||
expect(rules).to.deep.include({
|
||||
source: '2to3',
|
||||
component: 'Input',
|
||||
directives: { '--font': 'generic | Open Sans' },
|
||||
})
|
||||
expect(rules).to.deep.include({
|
||||
source: '2to3',
|
||||
component: 'RichContent',
|
||||
directives: { '--font': 'generic | Atkinson Hyperlegible' },
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue