From 3cb47aaab6f601157c967954f61cf0c86aac84f1 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 11 May 2022 10:10:20 -0400 Subject: [PATCH] Add test --- tests/arbitrary-values.test.js | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/arbitrary-values.test.js b/tests/arbitrary-values.test.js index baea4ddef..069393b1f 100644 --- a/tests/arbitrary-values.test.js +++ b/tests/arbitrary-values.test.js @@ -416,3 +416,78 @@ it('should correctly validate each part when checking for `percentage` data type `) }) }) + +it('arbitrary-value looking things in the config are preferred', () => { + let config = { + content: [{ raw: html`
` }], + corePlugins: { preflight: false, backgroundOpacity: false }, + plugins: [], + theme: { + colors: { + '[#c0ffee]': '#f0000d', + }, + }, + } + + let input = css` + @tailwind utilities; + ` + + return run(input, config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + .bg-\[\#c0ffee\] { + background-color: #f0000d; + } + `) + }) +}) + +it('modifier-value looking things in the config are preferred', () => { + let config = { + content: [{ raw: html`
` }], + corePlugins: { preflight: false, backgroundOpacity: false }, + plugins: [], + theme: { + colors: { + 'red-500/50': '#f0000d', + }, + }, + } + + let input = css` + @tailwind utilities; + ` + + return run(input, config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + .bg-red-500\/50 { + background-color: #f0000d; + } + `) + }) +}) + +it('modifier-value looking things in the config are preferred', () => { + let config = { + content: [{ raw: html`
` }], + corePlugins: { preflight: false, backgroundOpacity: false }, + plugins: [], + theme: { + colors: { + '[#ff0000]': '#f0000d', + }, + }, + } + + let input = css` + @tailwind utilities; + ` + + return run(input, config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + .bg-\[\#ff0000\]\/\[0\.5\] { + background-color: rgb(240 0 13 / 0.5); + } + `) + }) +})