Skip to content

Commit

Permalink
import 特性补充测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
Doma committed Mar 2, 2020
1 parent 573147c commit 971bf54
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/generate-themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const generateThemes = (themesConfig = {}, configs = {}) => {
const jsFileName = `${theme}.js`;
const importLines = getImportLines(config);
const modifyVariablesContent = getModifyVariablesContent(config);
const content = `${typeof lessContent === 'function' ? lessContent(theme, config) : [...importLines, lessContent].join('\r')}
const content = `${typeof lessContent === 'function' ? lessContent(theme, config) : [...importLines, lessContent].join('\n')}
${preHeader}
${modifyVariablesContent}`;
Expand Down
16 changes: 16 additions & 0 deletions test/generate-themes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ describe('Default generate.', () => {
generateThemes({
red: {
'base-color': '#ff0000'
},
dark: {
import: [
'~rsuite/lib/styles/themes/dark/index'
],
color: '#e5e5e5'
}
});
const outPutFilePath = path.resolve(process.cwd(), './src/src/less/themes');
Expand All @@ -34,6 +40,16 @@ import './red.less';`
@base-color:#ff0000;`
);
});

test('dark.less import validate', () => {
expect(readFile(resolvePath('dark.less'))).toEqual(
`@import '~rsuite/lib/styles/themes/dark/index';
@import "../index";
// Generate by Script.
@color:#e5e5e5;`
);
})
});

describe('Multiple themes generate.', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test('Output Name test', done => {
});
runCompiler(compiler).then(() => {
const dist = fs.readdirSync(`${outputPath}/css`);
expect(dist.length).toEqual(3);
expect(dist.length).toEqual(4);
expect(dist).toContain('theme-green.css');
expect(dist).toContain('theme-yellow.css');
expect(dist).toContain('theme-red.css');
Expand Down
3 changes: 3 additions & 0 deletions test/themes.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ module.exports = {
},
red: {
color: '#ff0000'
},
dark: {
color: '#e5e5e5'
}
};

0 comments on commit 971bf54

Please sign in to comment.