* WIP
* use `parse` instead of `defaultExtractor`
* skip `Vue` describe block
* add a few more dedicated arbitrary values/properties tests
* use parallel parsing
* splitup Vue tests
* add some Rust specific tests
* setup parse candidate strings test system
These tests will run against the `Regex` and `Rust` based parsers. We
have groups of classes of various shapes and forms + variants and
rendered in various template situation (plain, html, Vue, ...)
+ enable all skipped tests
* ensure we also validate the classes with variants
The classes with variants are built in the `templateTable` function, so
we get them out again by using the potional arguments of the `test.each`
cb function.
* cleanup test suite
* add "anti-test" tests
To make sure that we are _not_ parsing out certain values given a
certain input.
* Add ParseAction enum
* Restart parsing following an arbitrary parse failure
* Split variants off before validating the uility part
* Collapse candidate from the end when validation fails
* Support `<`, and `>` in variant position
* fix error
* format parser.rs
* Refactor
* Update editorconfig
* wip
* wip
* Refactor
* Refactor
* Simplify
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* run `cargo clippy --fix`
* run `cargo fmt`
* implement `cargo clippy` suggestions
These were not applied using `cargo clippy --fix`
* only allow `.` in the candidate part when surrounded by 0-9
This is only in the candidate part, not the arbitrary part.
* % characters can only appear at the end after digits
* > and < should only be part of variants (start OR end)
It can technically be inside the candidate when we have stacked
variants:
```
dark:<sm:underline
dark:md>:underline
```
* handle parsing utilities within quotes, parans or brackets
* mark `pt-1.5` as an expected value sliced out from `["pt-1.5"]`
* Add cursor abstraction
* wip
* disable the oxideParser if using a custom `prefix` or `separator`
* update tests
* Use cursor abstraction
* Refactor more code toward use of global cursor
* wip
* simplify
* Simplify
* Simplify
* Simplify
* Cleanup
* wip
* Simplify
* wip
* Simplify
* Handle candidates ending with % sign
* Tweak code a bit
* fmt
* Simplify
* Add cursor details to trace
* cargo fmt
* use preferred `zoom-0.5` name instead of `zoom-.5`
* drop over-extracted utilities in oxide parser
The RegEx parser does extract `underline` from
```html
<div class="peer-aria-[labelledby='a_b']:underline"></div>
```
... but that's not needed and is not happening in the oxide parser
This means that we have to make the output check a little bit different
but they are explicit based on the feature flag.
* allow extracting variants+utilities inside `{}` for the oxide parser
* characters in candidates such as `group-${id}` should not be allowed
* do not extract any of the following candidate `w-[foo-bar]w-[bar-baz]`
* ensure we can consume the full candidate and discard it
* Add fast skipping of whitespace
* Use fast skipping whenever possible
* Add fast skipping to benchmark
* Hand-tune to generate more optimized assembly
* Move code around a bit
This makes sure all the fancy SIMD stuff is as early as possible. This results in an extremely minor perf increase.
* Undo tweak
no meaningful perf difference in real world scenarios
* Disable fast skipping for now
It needs to be done in a different spot so it doesn’t affect how things are returned
* Change test names
* Fix normalize config error
* cleanup a bit
* Cleanup
* Extract validation result enum
* Cleanup comments
* Simplify
* Fix formatting
* Run clippy
* wip
* add `md>` under the special characters test set
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
279 lines
5.8 KiB
JavaScript
279 lines
5.8 KiB
JavaScript
import { run, html, css } from './util/run'
|
|
|
|
test('basic', () => {
|
|
let config = {
|
|
content: [
|
|
{
|
|
raw: html`
|
|
<div class="animate-spin"></div>
|
|
<div class="hover:animate-ping"></div>
|
|
<div class="group-hover:animate-bounce"></div>
|
|
`,
|
|
},
|
|
],
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes spin {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
.animate-spin {
|
|
animation: 1s linear infinite spin;
|
|
}
|
|
@keyframes ping {
|
|
75%,
|
|
100% {
|
|
opacity: 0;
|
|
transform: scale(2);
|
|
}
|
|
}
|
|
.hover\:animate-ping:hover {
|
|
animation: 1s cubic-bezier(0, 0, 0.2, 1) infinite ping;
|
|
}
|
|
@keyframes bounce {
|
|
0%,
|
|
100% {
|
|
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
|
|
transform: translateY(-25%);
|
|
}
|
|
50% {
|
|
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
transform: none;
|
|
}
|
|
}
|
|
.group:hover .group-hover\:animate-bounce {
|
|
animation: 1s infinite bounce;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('custom', () => {
|
|
let config = {
|
|
content: [{ raw: html`<div class="animate-one"></div>` }],
|
|
theme: {
|
|
extend: {
|
|
keyframes: {
|
|
one: { to: { transform: 'rotate(360deg)' } },
|
|
},
|
|
animation: {
|
|
one: 'one 2s',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes one {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
.animate-one {
|
|
animation: 2s one;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('custom prefixed', () => {
|
|
let config = {
|
|
prefix: 'tw-',
|
|
content: [{ raw: `<div class="tw-animate-one"></div>` }],
|
|
theme: {
|
|
extend: {
|
|
keyframes: {
|
|
one: { to: { transform: 'rotate(360deg)' } },
|
|
},
|
|
animation: {
|
|
one: 'one 2s',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes tw-one {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
.tw-animate-one {
|
|
animation: 2s tw-one;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('multiple', () => {
|
|
let config = {
|
|
content: [{ raw: html`<div class="animate-multiple"></div>` }],
|
|
theme: {
|
|
extend: {
|
|
animation: {
|
|
multiple: 'bounce 2s linear, pulse 3s ease-in',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes bounce {
|
|
0%,
|
|
100% {
|
|
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
|
|
transform: translateY(-25%);
|
|
}
|
|
50% {
|
|
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
transform: none;
|
|
}
|
|
}
|
|
@keyframes pulse {
|
|
50% {
|
|
opacity: 0.5;
|
|
}
|
|
}
|
|
.animate-multiple {
|
|
animation: 2s linear bounce, 3s ease-in pulse;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('multiple custom', () => {
|
|
let config = {
|
|
content: [{ raw: html`<div class="animate-multiple"></div>` }],
|
|
theme: {
|
|
extend: {
|
|
keyframes: {
|
|
one: { to: { transform: 'rotate(360deg)' } },
|
|
two: { to: { transform: 'scale(1.23)' } },
|
|
},
|
|
animation: {
|
|
multiple: 'one 2s, two 3s',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes one {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
@keyframes two {
|
|
to {
|
|
transform: scale(1.23);
|
|
}
|
|
}
|
|
.animate-multiple {
|
|
animation: 2s one, 3s two;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('with dots in the name', () => {
|
|
let config = {
|
|
content: [
|
|
{
|
|
raw: html`
|
|
<div class="animate-zoom-0.5"></div>
|
|
<div class="animate-zoom-1.5"></div>
|
|
`,
|
|
},
|
|
],
|
|
theme: {
|
|
extend: {
|
|
keyframes: {
|
|
'zoom-0.5': { to: { transform: 'scale(0.5)' } },
|
|
'zoom-1.5': { to: { transform: 'scale(1.5)' } },
|
|
},
|
|
animation: {
|
|
'zoom-0.5': 'zoom-0.5 2s',
|
|
'zoom-1.5': 'zoom-1.5 2s',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes zoom-0\.5 {
|
|
to {
|
|
transform: scale(0.5);
|
|
}
|
|
}
|
|
|
|
.animate-zoom-0\.5 {
|
|
animation: 2s zoom-0\.5;
|
|
}
|
|
|
|
@keyframes zoom-1\.5 {
|
|
to {
|
|
transform: scale(1.5);
|
|
}
|
|
}
|
|
|
|
.animate-zoom-1\.5 {
|
|
animation: 2s zoom-1\.5;
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('with dots in the name and prefix', () => {
|
|
let config = {
|
|
prefix: 'tw-',
|
|
content: [
|
|
{
|
|
raw: html`
|
|
<div class="tw-animate-zoom-.5"></div>
|
|
<div class="tw-animate-zoom-1.5"></div>
|
|
`,
|
|
},
|
|
],
|
|
theme: {
|
|
extend: {
|
|
keyframes: {
|
|
'zoom-.5': { to: { transform: 'scale(0.5)' } },
|
|
'zoom-1.5': { to: { transform: 'scale(1.5)' } },
|
|
},
|
|
animation: {
|
|
'zoom-.5': 'zoom-.5 2s',
|
|
'zoom-1.5': 'zoom-1.5 2s',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@keyframes tw-zoom-\.5 {
|
|
to {
|
|
transform: scale(0.5);
|
|
}
|
|
}
|
|
.tw-animate-zoom-\.5 {
|
|
animation: 2s tw-zoom-\.5;
|
|
}
|
|
@keyframes tw-zoom-1\.5 {
|
|
to {
|
|
transform: scale(1.5);
|
|
}
|
|
}
|
|
.tw-animate-zoom-1\.5 {
|
|
animation: 2s tw-zoom-1\.5;
|
|
}
|
|
`)
|
|
})
|
|
})
|