Skip to content

Commit 0b48b4c

Browse files
committed
Test that plugins can extend variants
1 parent 30a4e51 commit 0b48b4c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

__tests__/processPlugins.test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,3 +1946,60 @@ test('the configFunction parameter is optional when using the `createPlugin.with
19461946
expect(result.css).toMatchCss(expected)
19471947
})
19481948
})
1949+
1950+
test('plugins can extend variants', () => {
1951+
const plugin = createPlugin(function() {}, {
1952+
variants: {
1953+
opacity: ({ before }) => before(['active'], 'focus'),
1954+
},
1955+
})
1956+
1957+
return _postcss([
1958+
tailwind({
1959+
theme: {
1960+
opacity: { '0': '0', '100': '1' },
1961+
},
1962+
corePlugins: ['opacity'],
1963+
variants: { opacity: ({ without }) => without(['responsive']) },
1964+
plugins: [plugin],
1965+
}),
1966+
])
1967+
.process(
1968+
`
1969+
@tailwind base;
1970+
@tailwind components;
1971+
@tailwind utilities;
1972+
`,
1973+
{ from: undefined }
1974+
)
1975+
.then(result => {
1976+
const expected = `
1977+
.opacity-0 {
1978+
opacity: 0
1979+
}
1980+
.opacity-100 {
1981+
opacity: 1
1982+
}
1983+
.hover\\:opacity-0:hover {
1984+
opacity: 0
1985+
}
1986+
.hover\\:opacity-100:hover {
1987+
opacity: 1
1988+
}
1989+
.active\\:opacity-0:active {
1990+
opacity: 0
1991+
}
1992+
.active\\:opacity-100:active {
1993+
opacity: 1
1994+
}
1995+
.focus\\:opacity-0:focus {
1996+
opacity: 0
1997+
}
1998+
.focus\\:opacity-100:focus {
1999+
opacity: 1
2000+
}
2001+
`
2002+
2003+
expect(result.css).toMatchCss(expected)
2004+
})
2005+
})

0 commit comments

Comments
 (0)