|
| 1 | +import { run, html, css } from '../util/run' |
| 2 | + |
| 3 | +test('font-family utilities can be defined as a string', () => { |
| 4 | + let config = { |
| 5 | + content: [{ raw: html`<div class="font-sans"></div>` }], |
| 6 | + theme: { |
| 7 | + fontFamily: { |
| 8 | + sans: 'Helvetica, Arial, sans-serif', |
| 9 | + }, |
| 10 | + }, |
| 11 | + } |
| 12 | + |
| 13 | + return run('@tailwind utilities', config).then((result) => { |
| 14 | + expect(result.css).toMatchCss(css` |
| 15 | + .font-sans { |
| 16 | + font-family: Helvetica, Arial, sans-serif; |
| 17 | + } |
| 18 | + `) |
| 19 | + }) |
| 20 | +}) |
| 21 | + |
| 22 | +test('font-family utilities can be defined as an array', () => { |
| 23 | + let config = { |
| 24 | + content: [{ raw: html`<div class="font-sans"></div>` }], |
| 25 | + theme: { |
| 26 | + fontFamily: { |
| 27 | + sans: ['Helvetica', 'Arial', 'sans-serif'], |
| 28 | + }, |
| 29 | + }, |
| 30 | + } |
| 31 | + |
| 32 | + return run('@tailwind utilities', config).then((result) => { |
| 33 | + expect(result.css).toMatchCss(css` |
| 34 | + .font-sans { |
| 35 | + font-family: Helvetica, Arial, sans-serif; |
| 36 | + } |
| 37 | + `) |
| 38 | + }) |
| 39 | +}) |
| 40 | + |
| 41 | +test('font-family values are not automatically escaped', () => { |
| 42 | + let config = { |
| 43 | + content: [{ raw: html`<div class="font-sans"></div>` }], |
| 44 | + theme: { |
| 45 | + fontFamily: { |
| 46 | + sans: ["'Exo 2'", 'sans-serif'], |
| 47 | + }, |
| 48 | + }, |
| 49 | + } |
| 50 | + |
| 51 | + return run('@tailwind utilities', config).then((result) => { |
| 52 | + expect(result.css).toMatchCss(css` |
| 53 | + .font-sans { |
| 54 | + font-family: 'Exo 2', sans-serif; |
| 55 | + } |
| 56 | + `) |
| 57 | + }) |
| 58 | +}) |
| 59 | + |
| 60 | +test('font-feature-settings can be provided when families are defined as a string', () => { |
| 61 | + let config = { |
| 62 | + content: [{ raw: html`<div class="font-sans"></div>` }], |
| 63 | + theme: { |
| 64 | + fontFamily: { |
| 65 | + sans: ['Helvetica, Arial, sans-serif', { fontFeatureSettings: '"cv11", "ss01"' }], |
| 66 | + }, |
| 67 | + }, |
| 68 | + } |
| 69 | + |
| 70 | + return run('@tailwind utilities', config).then((result) => { |
| 71 | + expect(result.css).toMatchCss(` |
| 72 | + .font-sans { |
| 73 | + font-family: Helvetica, Arial, sans-serif; |
| 74 | + font-feature-settings: "cv11", "ss01"; |
| 75 | + } |
| 76 | + `) |
| 77 | + }) |
| 78 | +}) |
| 79 | + |
| 80 | +test('font-feature-settings can be provided when families are defined as an array', () => { |
| 81 | + let config = { |
| 82 | + content: [{ raw: html`<div class="font-sans"></div>` }], |
| 83 | + theme: { |
| 84 | + fontFamily: { |
| 85 | + sans: [['Helvetica', 'Arial', 'sans-serif'], { fontFeatureSettings: '"cv11", "ss01"' }], |
| 86 | + }, |
| 87 | + }, |
| 88 | + } |
| 89 | + |
| 90 | + return run('@tailwind utilities', config).then((result) => { |
| 91 | + expect(result.css).toMatchCss(` |
| 92 | + .font-sans { |
| 93 | + font-family: Helvetica, Arial, sans-serif; |
| 94 | + font-feature-settings: "cv11", "ss01"; |
| 95 | + } |
| 96 | + `) |
| 97 | + }) |
| 98 | +}) |
0 commit comments