fix: importStyle test case (#471)

This commit is contained in:
luhc228 2022-08-22 15:35:45 +08:00 committed by ClarkXia
parent 63fe64ee5b
commit 22931664a6
1 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ describe('import style', () => {
it('simple import', async () => { it('simple import', async () => {
const sourceCode = `import { Button } from 'antd';`; const sourceCode = `import { Button } from 'antd';`;
const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); const result = await importStyle(sourceCode, { libraryName: 'antd', style: true });
expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/Button/style';`); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`);
}); });
it('custom style', async () => { it('custom style', async () => {
const sourceCode = `import { Button } from 'antd';`; const sourceCode = `import { Button } from 'antd';`;
@ -20,12 +20,12 @@ describe('import style', () => {
it('multiple import', async () => { it('multiple import', async () => {
const sourceCode = `import { Button, Table } from 'antd';`; const sourceCode = `import { Button, Table } from 'antd';`;
const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); const result = await importStyle(sourceCode, { libraryName: 'antd', style: true });
expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/Button/style';\nimport 'antd/es/Table/style';`); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';\nimport 'antd/es/table/style';`);
}); });
it('named import', async () => { it('named import', async () => {
const sourceCode = `import { Button as Btn } from 'antd';`; const sourceCode = `import { Button as Btn } from 'antd';`;
const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); const result = await importStyle(sourceCode, { libraryName: 'antd', style: true });
expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/Button/style';`); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`);
}); });
it('default import', async () => { it('default import', async () => {
const sourceCode = `import * as antd from 'antd';`; const sourceCode = `import * as antd from 'antd';`;