diff --git a/example/webpack/App.svelte b/example/webpack/App.svelte index fb35269..6265389 100644 --- a/example/webpack/App.svelte +++ b/example/webpack/App.svelte @@ -1,5 +1,5 @@ \nRed'; + +test('Customize generated classname from getLocalIdent', async () => { + const output = await compiler({ + source, + }, { + localIdentName: '[local]-123456MC', + getLocalIdent: (context, { interpolatedName }) => { + return interpolatedName.toLowerCase(); + } + }); + + expect(output).toBe('\nRed'); +}); \ No newline at end of file diff --git a/test/path.test.js b/test/path.test.js index 2d63f6d..b7edb4a 100644 --- a/test/path.test.js +++ b/test/path.test.js @@ -6,6 +6,7 @@ const sourceReactiveClass = '\n { const output = await compiler({ source, + }, { localIdentName: '[path][name]__[local]', }); @@ -15,6 +16,7 @@ test('Replace path on regular class', async () => { test('Replace path on reactive class', async () => { const output = await compiler({ source: sourceReactiveClass, + }, { localIdentName: '[path][name]__[local]', }); diff --git a/test/remove.test.js b/test/remove.test.js index cd2de6e..1631bf8 100644 --- a/test/remove.test.js +++ b/test/remove.test.js @@ -7,6 +7,7 @@ const expectedOutput = '\nBlue test('Remove unused CSS Modules from HTML attribute', async () => { const output = await compiler({ source, + }, { localIdentName: '[local]-123456', }); @@ -15,6 +16,7 @@ test('Remove unused CSS Modules from HTML attribute', async () => { test('[Shorthand] Remove unused CSS Modules from HTML attribute', async () => { const output = await compiler({ source: sourceShorthand, + }, { localIdentName: '[local]-123456', }); diff --git a/test/replace.test.js b/test/replace.test.js index 220b21d..48da01c 100644 --- a/test/replace.test.js +++ b/test/replace.test.js @@ -6,6 +6,7 @@ const sourceShorthand = '\nRed'); @@ -30,6 +33,7 @@ test('Avoid generated class to start with a non character', async () => { test('[Shorthand] Avoid generated class to start with a non character', async () => { const output = await compiler({ source: sourceShorthand, + }, { localIdentName: '1[local]', }); expect(output).toBe('\nRed'); @@ -38,6 +42,7 @@ test('[Shorthand] Avoid generated class to start with a non character', async () test('Avoid generated class to end with a hyphen', async () => { const output = await compiler({ source, + }, { localIdentName: '[local]-', }); expect(output).toBe('\nRed'); @@ -45,6 +50,7 @@ test('Avoid generated class to end with a hyphen', async () => { test('[Shorthand] Avoid generated class to end with a hyphen', async () => { const output = await compiler({ source: sourceShorthand, + }, { localIdentName: '[local]-', }); expect(output).toBe('\nRed'); diff --git a/test/target.test.js b/test/target.test.js index 5823672..88cb4d0 100644 --- a/test/target.test.js +++ b/test/target.test.js @@ -33,6 +33,7 @@ const expectedOutput = test('Target proper className from lookalike classNames', async () => { const output = await compiler({ source, + }, { localIdentName: '[local]-123', }); @@ -42,6 +43,7 @@ test('Target proper className from lookalike classNames', async () => { test('[Shorthand] Target proper className from lookalike classNames', async () => { const output = await compiler({ source: sourceShorthand, + }, { localIdentName: '[local]-123', }); diff --git a/test/toggle.test.js b/test/toggle.test.js index 76efd9d..62e174c 100644 --- a/test/toggle.test.js +++ b/test/toggle.test.js @@ -23,6 +23,7 @@ const expectedOutput = test('Generate CSS Modules className on class binding', async () => { const output = await compiler({ source, + }, { localIdentName: '[local]-123456', }); @@ -32,6 +33,7 @@ test('Generate CSS Modules className on class binding', async () => { test('[Shorthand] Generate CSS Modules className on class binding', async () => { const output = await compiler({ source: sourceShorthand, + }, { localIdentName: '[local]-123456', });