Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/hacknug/tailwindcss-text-indent. Text-indent utilities for Tailwind CSS. www.npmjs.com/package/tailwindcss-text-indent
Something went wrong. Try again.
tailwindcss-text-indent test.js
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151const _ = require('lodash')
const plugin = require('./index.js')const postcss = require('postcss')const tailwindcss = require('tailwindcss')
// const defaultConfig = require('tailwindcss/defaultConfig')const generatePluginCss = (testConfig = {}, pluginOptions = {}) => { const sandboxConfig = { theme: { screens: { 'sm': '640px' }, }, corePlugins: false, plugins: [ plugin(pluginOptions) ], } const postcssPlugins =[ tailwindcss(_.merge(sandboxConfig, testConfig)), ]
return postcss(postcssPlugins) .process('@tailwind utilities', { from: undefined }) .then(result => result.css)}
expect.extend({ toMatchCss: require('jest-matcher-css') })
test('generates default utilities and responsive variants', () => { const testConfig = {} const expectedCss = ``
return generatePluginCss(testConfig).then(css => expect(css).toMatchCss(expectedCss))})
test('variants can be customized', () => { const testConfig = { theme: { textIndent: { sm: '2rem', md: '3rem', lg: '4rem', }, }, variants: { textIndent: [ 'hover' ], }, } const expectedCss = ` .indent-sm { text-indent: 2rem; } .indent-md { text-indent: 3rem; } .indent-lg { text-indent: 4rem; }
.hover\\:indent-sm:hover { text-indent: 2rem; } .hover\\:indent-md:hover { text-indent: 3rem; } .hover\\:indent-lg:hover { text-indent: 4rem; } `
return generatePluginCss(testConfig).then(css => expect(css).toMatchCss(expectedCss))})
test('utilities can be customized', () => { const testConfig = { theme: { textIndent: { sm: '2rem', md: '3rem', lg: '4rem', }, }, } const expectedCss = ` .indent-sm { text-indent: 2rem; } .indent-md { text-indent: 3rem; } .indent-lg { text-indent: 4rem; }
@media (min-width: 640px) { .sm\\:indent-sm { text-indent: 2rem; } .sm\\:indent-md { text-indent: 3rem; } .sm\\:indent-lg { text-indent: 4rem; } } `
return generatePluginCss(testConfig).then(css => expect(css).toMatchCss(expectedCss))})
test('generates negative utilities', () => { const testConfig = { theme: { textIndent: (theme, { negative }) => ({ ...negative({ sm: '2rem', md: '3rem', lg: '4rem', }) }), }, } const expectedCss = ` .-indent-sm { text-indent: -2rem } .-indent-md { text-indent: -3rem } .-indent-lg { text-indent: -4rem }
@media (min-width: 640px) { .sm\\:-indent-sm { text-indent: -2rem } .sm\\:-indent-md { text-indent: -3rem } .sm\\:-indent-lg { text-indent: -4rem } } `
return generatePluginCss(testConfig).then(css => expect(css).toMatchCss(expectedCss))})
test('handles mixed utilities correctly', () => { const testConfig = { theme: { textIndent: (theme, { negative }) => ({ ...{ sm: '2rem', md: '3rem', lg: '4rem', }, ...negative({ sm: '2rem', md: '3rem', lg: '4rem', }) }), }, } const expectedCss = ` .indent-sm { text-indent: 2rem } .indent-md { text-indent: 3rem } .indent-lg { text-indent: 4rem }
.-indent-sm { text-indent: -2rem } .-indent-md { text-indent: -3rem } .-indent-lg { text-indent: -4rem }
@media (min-width: 640px) { .sm\\:indent-sm { text-indent: 2rem } .sm\\:indent-md { text-indent: 3rem } .sm\\:indent-lg { text-indent: 4rem }
.sm\\:-indent-sm { text-indent: -2rem } .sm\\:-indent-md { text-indent: -3rem } .sm\\:-indent-lg { text-indent: -4rem } } `
return generatePluginCss(testConfig).then(css => expect(css).toMatchCss(expectedCss))})