Skip to content

Commit ed6deaf

Browse files
Add failing tests
1 parent 1c905f2 commit ed6deaf

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

crates/oxide/tests/scanner.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,32 @@ mod scanner {
415415
assert_eq!(candidates, vec!["content-['foo.styl']"]);
416416
}
417417

418+
#[test]
419+
fn it_should_scan_next_dynamic_folders() {
420+
let candidates = scan_with_globs(
421+
&[
422+
// We know that `.styl` extensions are ignored, so they are not covered by auto content
423+
// detection.
424+
("app/[slug]/page.styl", "content-['[slug]']"),
425+
("app/[...slug]/page.styl", "content-['[...slug]']"),
426+
("app/[[...slug]]/page.styl", "content-['[[...slug]]']"),
427+
("app/(theme)/page.styl", "content-['(theme)']"),
428+
],
429+
vec!["./**/*.{styl}"],
430+
)
431+
.1;
432+
433+
assert_eq!(
434+
candidates,
435+
vec![
436+
"content-['(theme)']",
437+
"content-['[slug]']",
438+
"content-['[...slug]']",
439+
"content-['[[...slug]]']",
440+
],
441+
);
442+
}
443+
418444
#[test]
419445
fn it_should_scan_absolute_paths() {
420446
// Create a temporary working directory

integrations/postcss/next.test.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,89 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
162162
},
163163
)
164164
})
165+
166+
test.only(
167+
'should scan dynamic route segments',
168+
{
169+
fs: {
170+
'package.json': json`
171+
{
172+
"dependencies": {
173+
"react": "^18",
174+
"react-dom": "^18",
175+
"next": "^14"
176+
},
177+
"devDependencies": {
178+
"@tailwindcss/postcss": "workspace:^",
179+
"tailwindcss": "workspace:^"
180+
}
181+
}
182+
`,
183+
'postcss.config.mjs': js`
184+
/** @type {import('postcss-load-config').Config} */
185+
const config = {
186+
plugins: {
187+
'@tailwindcss/postcss': {},
188+
},
189+
}
190+
191+
export default config
192+
`,
193+
'next.config.mjs': js`
194+
/** @type {import('next').NextConfig} */
195+
const nextConfig = {}
196+
197+
export default nextConfig
198+
`,
199+
'app/a/[slug]/page.js': js`
200+
export default function Page() {
201+
return <h1 className="content-['[slug]']">Hello, Next.js!</h1>
202+
}
203+
`,
204+
'app/b/[...slug]/page.js': js`
205+
export default function Page() {
206+
return <h1 className="content-['[...slug]']">Hello, Next.js!</h1>
207+
}
208+
`,
209+
'app/c/[[...slug]]/page.js': js`
210+
export default function Page() {
211+
return <h1 className="content-['[[...slug]]']">Hello, Next.js!</h1>
212+
}
213+
`,
214+
'app/d/(theme)/page.js': js`
215+
export default function Page() {
216+
return <h1 className="content-['(theme)']">Hello, Next.js!</h1>
217+
}
218+
`,
219+
'app/layout.js': js`
220+
import './globals.css'
221+
222+
export default function RootLayout({ children }) {
223+
return (
224+
<html>
225+
<body>{children}</body>
226+
</html>
227+
)
228+
}
229+
`,
230+
'app/globals.css': css`
231+
@import 'tailwindcss/utilities' source(none);
232+
@source './**/*.{js,ts,jsx,tsx,mdx}';
233+
`,
234+
},
235+
},
236+
async ({ fs, exec, expect }) => {
237+
await exec('pnpm next build')
238+
239+
let files = await fs.glob('.next/static/css/**/*.css')
240+
expect(files).toHaveLength(1)
241+
let [filename] = files[0]
242+
243+
await fs.expectFileToContain(filename, [
244+
candidate`content-['[slug]']`,
245+
candidate`content-['[...slug]']`,
246+
candidate`content-['[[...slug]]']`,
247+
candidate`content-['(theme)']`,
248+
])
249+
},
250+
)

0 commit comments

Comments
 (0)