Skip to content

Commit

Permalink
Add missing test (#23)
Browse files Browse the repository at this point in the history
* Add missing test

Test result check is missing a class which makes the test give a false negative (false pass).

* Update test

* Tweak matcher

* Update to latest insiders version

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
  • Loading branch information
sarimarton and thecrypticace authored Dec 5, 2023
1 parent c287ac7 commit a10d21f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 38 deletions.
7 changes: 6 additions & 1 deletion jest/custom-matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ expect.extend({
printWidth: 100,
})
}

function stripped(str) {
return str.replace(/\/\* ! tailwindcss .* \*\//, '').replace(/\s/g, '').replace(/;/g, '')
}

const options = {
comment: 'stripped(received) === stripped(argument)',
isNot: this.isNot,
Expand All @@ -116,7 +121,7 @@ expect.extend({
let formattedReceived = format(received)
let formattedArgument = format(argument)

const pass = formattedReceived === formattedArgument
const pass = stripped(formattedReceived) === stripped(formattedArgument)

const message = pass
? () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"jest": "^29.1.2",
"postcss": "^8.4.17",
"prettier": "^2.7.1",
"tailwindcss": "0.0.0-insiders.3011f46",
"tailwindcss": "0.0.0-insiders.7385373",
"typescript": "^4.8.4"
}
}
74 changes: 38 additions & 36 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('container queries', () => {
{
raw: html`
<div
class="@container @container-normal @container/sidebar @container-normal/sidebar @container-[size]/sidebar"
class="@container @container-normal @container/sidebar @container-normal/sidebar @container-[size] @container-[size]/sidebar"
>
<div class="@md:underline"></div>
<div class="@md/container1:underline"></div>
Expand Down Expand Up @@ -54,111 +54,113 @@ it('container queries', () => {
container-type: inline-size;
}
.\@container-\[size\] {
container-type: size;
}
.\@container-\[size\]\/sidebar {
container: sidebar / size;
}
.\@container-normal {
container-type: normal;
}
.\@container\/sidebar {
container-type: inline-size;
container-name: sidebar;
.\@container-normal\/sidebar {
container: sidebar;
}
.\@container-normal\/sidebar {
container-type: normal;
container-name: sidebar;
.\@container\/sidebar {
container: sidebar / inline-size;
}
@container (min-width: 123px) {
@container (width >= 123px) {
.\@\[123px\]\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 200rem) {
@container (width >= 200rem) {
.\@\[200rem\]\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 312px) {
@container (width >= 312px) {
.\@\[312px\]\:underline {
text-decoration-line: underline;
}
}
@container container1 (min-width: 320px) {
@container container1 (width >= 320px) {
.\@sm\/container1\:underline {
text-decoration-line: underline;
}
}
@container container2 (min-width: 320px) {
@container container2 (width >= 320px) {
.\@sm\/container2\:underline {
text-decoration-line: underline;
}
}
@container container10 (min-width: 320px) {
@container container10 (width >= 320px) {
.\@sm\/container10\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 320px) {
@container (width >= 320px) {
.\@sm\:underline {
text-decoration-line: underline;
}
}
@container container1 (min-width: 768px) {
@container container1 (width >= 768px) {
.\@md\/container1\:underline {
text-decoration-line: underline;
}
}
@container container2 (min-width: 768px) {
@container container2 (width >= 768px) {
.\@md\/container2\:underline {
text-decoration-line: underline;
}
}
@container container10 (min-width: 768px) {
@container container10 (width >= 768px) {
.\@md\/container10\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 768px) {
@container (width >= 768px) {
.\@md\:underline {
text-decoration-line: underline;
}
}
@container container1 (min-width: 1024px) {
.\@lg\/container1\:underline {
text-decoration-line: underline;
}
@container container1 (width >= 1024px) {
.\@lg\/container1\:underline,
.\@\[1024px\]\/container1\:underline {
text-decoration-line: underline;
}
}
@container container2 (min-width: 1024px) {
@container container2 (width >= 1024px) {
.\@lg\/container2\:underline {
text-decoration-line: underline;
}
}
@container container10 (min-width: 1024px) {
@container container10 (width >= 1024px) {
.\@lg\/container10\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 1024px) {
.\@lg\:underline {
text-decoration-line: underline;
}
@container (width >= 1024px) {
.\@lg\:underline,
.\@\[1024px\]\:underline {
text-decoration-line: underline;
}
Expand Down Expand Up @@ -195,49 +197,49 @@ it('should be possible to use default container queries', () => {

return run(input, config).then((result) => {
expect(result.css).toMatchFormattedCss(css`
@container (min-width: 20rem) {
@container (width >= 20rem) {
.\@xs\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 24rem) {
@container (width >= 24rem) {
.\@sm\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 28rem) {
@container (width >= 28rem) {
.\@md\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 32rem) {
@container (width >= 32rem) {
.\@lg\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 48rem) {
@container (width >= 48rem) {
.\@3xl\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 64rem) {
@container (width >= 64rem) {
.\@5xl\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 72rem) {
@container (width >= 72rem) {
.\@6xl\:underline {
text-decoration-line: underline;
}
}
@container (min-width: 80rem) {
@container (width >= 80rem) {
.\@7xl\:underline {
text-decoration-line: underline;
}
Expand Down

0 comments on commit a10d21f

Please sign in to comment.