fontFamily.test.js 2.4 KB

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