Skip to content

Commit d91c2d2

Browse files
committed
tdd
1 parent 86f295e commit d91c2d2

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tests/specs/patched/postcss.spec.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ export default testSuite(({ describe }) => {
551551
await using fixture = await createFixture(fixtures.composedAndFlat);
552552

553553
const { js } = await viteBuild(fixture.path, {
554-
plugins: [patchCssModules({ composedClassesMode: 'string' })],
554+
plugins: [patchCssModules({
555+
composedClassesMode: 'string',
556+
generateSourceTypes: true,
557+
})],
555558
build: {
556559
target: 'es2022',
557560
},
@@ -563,13 +566,19 @@ export default testSuite(({ describe }) => {
563566
composed: expect.stringMatching(/_composed_\w+ _plain_\w+/),
564567
},
565568
});
569+
const dts = await fixture.readFile('style.module.css.d.ts', 'utf8');
570+
expect(dts).toMatch('const plain: string;');
571+
expect(dts).toMatch('const composed: string;');
566572
});
567573

568574
test('array', async () => {
569575
await using fixture = await createFixture(fixtures.composedAndFlat);
570576

571577
const { js } = await viteBuild(fixture.path, {
572-
plugins: [patchCssModules({ composedClassesMode: 'array' })],
578+
plugins: [patchCssModules({
579+
composedClassesMode: 'array',
580+
generateSourceTypes: true,
581+
})],
573582
build: {
574583
target: 'es2022',
575584
},
@@ -581,13 +590,19 @@ export default testSuite(({ describe }) => {
581590
composed: [expect.stringMatching(/_composed_\w+/), expect.stringMatching(/_plain_\w+/)],
582591
},
583592
});
593+
const dts = await fixture.readFile('style.module.css.d.ts', 'utf8');
594+
expect(dts).toMatch('const plain: string;');
595+
expect(dts).toMatch('const composed: string[];');
584596
});
585597

586598
test('all-array', async () => {
587599
await using fixture = await createFixture(fixtures.composedAndFlat);
588600

589601
const { js } = await viteBuild(fixture.path, {
590-
plugins: [patchCssModules({ composedClassesMode: 'all-array' })],
602+
plugins: [patchCssModules({
603+
composedClassesMode: 'all-array',
604+
generateSourceTypes: true,
605+
})],
591606
build: {
592607
target: 'es2022',
593608
},
@@ -599,6 +614,9 @@ export default testSuite(({ describe }) => {
599614
composed: [expect.stringMatching(/_composed_\w+/), expect.stringMatching(/_plain_\w+/)],
600615
},
601616
});
617+
const dts = await fixture.readFile('style.module.css.d.ts', 'utf8');
618+
expect(dts).toMatch('const plain: string[];');
619+
expect(dts).toMatch('const composed: string[];');
602620
});
603621
});
604622

0 commit comments

Comments
 (0)