diff --git a/themebuilder/tests/builder-spec.js b/themebuilder/tests/builder-spec.js index 4221d6bf4656..38eee93b37cc 100644 --- a/themebuilder/tests/builder-spec.js +++ b/themebuilder/tests/builder-spec.js @@ -4,7 +4,6 @@ const path = require('path'); const assert = require('chai').assert; const buildTheme = require('../modules/builder').buildTheme; const commands = require('../modules/commands'); -const mock = require('mock-require'); const fileReader = (filename) => { filename = filename.replace('devextreme-themebuilder/', ''); @@ -120,23 +119,6 @@ describe('Builder - testing exported function', () => { }); describe('Check if all widgets can be compiled separately', () => { - let buildThemeWithMockedCleanCss = {}; - - beforeEach(() => { - mock('clean-css', class CleanCss { - minify(css) { - return { styles: css }; - } - }); - mock.reRequire('clean-css'); - mock.reRequire('../modules/less-template-loader'); - buildThemeWithMockedCleanCss = mock.reRequire('../modules/builder').buildTheme; - }); - - afterEach(() => { - mock.stopAll(); - }); - ['generic.light', 'material.blue.light'].forEach(theme => { const ModulesHandler = require('../modules/modules-handler'); const themesFileContent = fs.readFileSync(path.join(__dirname, '../../styles/theme.less'), 'utf8'); @@ -150,15 +132,16 @@ describe('Check if all widgets can be compiled separately', () => { lessCompiler: lessCompiler, items: [], baseTheme: theme, - widgets: [widgetName] + widgets: [widgetName], + noClean: true }; it(`We can build bundle for every widget (${theme}, ${widgetName})`, () => { - return buildThemeWithMockedCleanCss(config).then((result) => { + return buildTheme(config).then((result) => { assert.isString(result.css, `${widgetName} bundle builded`); assert.deepEqual(result.widgets, [ widgetName ]); }); - }); + }).timeout(buildTimeout); }); }); }); diff --git a/themebuilder/tests/less-template-loader-spec.js b/themebuilder/tests/less-template-loader-spec.js index e8a812f7cfb1..8f8e074079f8 100644 --- a/themebuilder/tests/less-template-loader-spec.js +++ b/themebuilder/tests/less-template-loader-spec.js @@ -602,38 +602,28 @@ describe('LessTemplateLoader', () => { }; const lessTemplateLoader = new LessTemplateLoader(config); - lessTemplateLoader._makeInfoHeader = emptyHeader; - - const promises = []; - - promises.push(lessTemplateLoader.load( - themeName, - colorScheme, - metadata, - [] - ).then(data => { - assert.equal(data.css, `div { - font: 20px/20px DXIcons; -}`); - })); config.noClean = true; const lessTemplateLoaderNoClean = new LessTemplateLoader(config); + lessTemplateLoaderNoClean._makeInfoHeader = emptyHeader; - promises.push(lessTemplateLoaderNoClean.load( + lessTemplateLoader._makeInfoHeader = emptyHeader; + + const testCases = [{ + loader: lessTemplateLoader, + expected: 'div {\n font: 20px/20px DXIcons;\n}' + }, { + loader: lessTemplateLoaderNoClean, + expected: 'div {\n font: 14px/1 DXIcons;\n font-size: 20px;\n line-height: 20px;\n}\n' + }]; + + const promises = testCases.map(testCase => testCase.loader.load( themeName, colorScheme, metadata, [] - ).then(data => { - assert.equal(data.css, `div { - font: 14px/1 DXIcons; - font-size: 20px; - line-height: 20px; -} -`); - })); + ).then(data => assert.equal(data.css, testCase.expected))); - return promises; + return Promise.all(promises); }); });