123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- import { run, html, css } from './util/run'
- test('using a negative prefix with a negative scale value', () => {
- let config = {
- content: [{ raw: html`<div class="mt-2 -mt-2"></div>` }],
- theme: {
- margin: {
- 2: '8px',
- '-2': '-4px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-2 {
- margin-top: 8px;
- }
- .-mt-2 {
- margin-top: -4px;
- }
- `)
- })
- })
- test('using a negative scale value with a plugin that does not support dynamic negative values', () => {
- let config = {
- content: [{ raw: html`<div class="-opacity-50"></div>` }],
- theme: {
- opacity: {
- '-50': '0.5',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .-opacity-50 {
- opacity: 0.5;
- }
- `)
- })
- })
- test('using a negative prefix without a negative scale value', () => {
- let config = {
- content: [{ raw: html`<div class="mt-5 -mt-5"></div>` }],
- theme: {
- margin: {
- 5: '20px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-5 {
- margin-top: 20px;
- }
- .-mt-5 {
- margin-top: -20px;
- }
- `)
- })
- })
- test('being an asshole', () => {
- let config = {
- content: [{ raw: html`<div class="-mt-[10px]"></div>` }],
- theme: {
- margin: {
- '-[10px]': '55px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .-mt-\[10px\] {
- margin-top: 55px;
- }
- `)
- })
- })
- test('being a real asshole', () => {
- let config = {
- content: [{ raw: html`<div class="-mt-[10px]"></div>` }],
- theme: {
- margin: {
- '[10px]': '55px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .-mt-\[10px\] {
- margin-top: -55px;
- }
- `)
- })
- })
- test('a value that includes a variable', () => {
- let config = {
- content: [{ raw: html`<div class="mt-5 -mt-5"></div>` }],
- theme: {
- margin: {
- 5: 'var(--sizing-5)',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-5 {
- margin-top: var(--sizing-5);
- }
- .-mt-5 {
- margin-top: calc(var(--sizing-5) * -1);
- }
- `)
- })
- })
- test('a value that includes a calc', () => {
- let config = {
- content: [{ raw: html`<div class="mt-5 -mt-5"></div>` }],
- theme: {
- margin: {
- 5: 'calc(52px * -3)',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-5 {
- margin-top: calc(52px * -3);
- }
- .-mt-5 {
- margin-top: calc(calc(52px * -3) * -1);
- }
- `)
- })
- })
- test('a value that includes min/max/clamp functions', () => {
- let config = {
- content: [{ raw: html`<div class="mt-min -mt-min mt-max -mt-max mt-clamp -mt-clamp"></div>` }],
- theme: {
- margin: {
- 'min': 'min(100vmin, 3rem)',
- 'max': 'max(100vmax, 3rem)',
- 'clamp': 'clamp(1rem, 100vh, 3rem)',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-min {
- margin-top: min(100vmin, 3rem);
- }
- .-mt-min {
- margin-top: calc(min(100vmin, 3rem) * -1);
- }
- .mt-max {
- margin-top: max(100vmax, 3rem);
- }
- .-mt-max {
- margin-top: calc(max(100vmax, 3rem) * -1);
- }
- .mt-clamp {
- margin-top: clamp(1rem, 100vh, 3rem);
- }
- .-mt-clamp {
- margin-top: calc(clamp(1rem, 100vh, 3rem) * -1);
- }
- `)
- })
- })
- test('a keyword value', () => {
- let config = {
- content: [{ raw: html`<div class="-mt-auto mt-auto"></div>` }],
- theme: {
- margin: {
- auto: 'auto',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-auto {
- margin-top: auto;
- }
- `)
- })
- })
- test('a zero value', () => {
- let config = {
- content: [{ raw: html`<div class="mt-0 -mt-0"></div>` }],
- theme: {
- margin: {
- 0: '0',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt-0 {
- margin-top: 0;
- }
- .-mt-0 {
- margin-top: 0;
- }
- `)
- })
- })
- test('a color', () => {
- let config = {
- content: [{ raw: html`<div class="-bg-red"></div>` }],
- theme: {
- colors: {
- red: 'red',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css``)
- })
- })
- test('arbitrary values', () => {
- let config = {
- content: [{ raw: html`<div class="-mt-[10px]"></div>` }],
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .-mt-\[10px\] {
- margin-top: -10px;
- }
- `)
- })
- })
- test('negating a negative scale value', () => {
- let config = {
- content: [{ raw: html`<div class="-mt-weird"></div>` }],
- theme: {
- margin: {
- weird: '-15px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .-mt-weird {
- margin-top: 15px;
- }
- `)
- })
- })
- test('negating a default value', () => {
- let config = {
- content: [{ raw: html`<div class="-mt"></div>` }],
- theme: {
- margin: {
- DEFAULT: '15px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .-mt {
- margin-top: -15px;
- }
- `)
- })
- })
- test('using a negative prefix with a negative default scale value', () => {
- let config = {
- content: [{ raw: html`<div class="mt -mt"></div>` }],
- theme: {
- margin: {
- DEFAULT: '8px',
- '-DEFAULT': '-4px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .mt {
- margin-top: 8px;
- }
- .-mt {
- margin-top: -4px;
- }
- `)
- })
- })
- test('negating a default value with a configured prefix', () => {
- let config = {
- prefix: 'tw-',
- content: [{ raw: html`<div class="tw--mt"></div>` }],
- theme: {
- margin: {
- DEFAULT: '15px',
- },
- },
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css`
- .tw--mt {
- margin-top: -15px;
- }
- `)
- })
- })
- test('arbitrary value keywords should be ignored', () => {
- let config = {
- content: [{ raw: html`<div class="-mt-[auto]"></div>` }],
- }
- return run('@tailwind utilities', config).then((result) => {
- return expect(result.css).toMatchCss(css``)
- })
- })
|