1 | var lessTest = require('./less-test'),
|
---|
2 | lessTester = lessTest(),
|
---|
3 | path = require('path'),
|
---|
4 | stylize = require('../lib/less-node/lessc-helper').stylize,
|
---|
5 | nock = require('nock');
|
---|
6 |
|
---|
7 | console.log('\n' + stylize('Less', 'underline') + '\n');
|
---|
8 |
|
---|
9 | var testMap = [
|
---|
10 | [{
|
---|
11 | // TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
|
---|
12 | relativeUrls: true,
|
---|
13 | silent: true,
|
---|
14 | javascriptEnabled: true
|
---|
15 | }, '_main/'],
|
---|
16 | [{}, 'namespacing/'],
|
---|
17 | [{
|
---|
18 | math: 'parens'
|
---|
19 | }, 'math/strict/'],
|
---|
20 | [{
|
---|
21 | math: 'parens-division'
|
---|
22 | }, 'math/parens-division/'],
|
---|
23 | [{
|
---|
24 | math: 'always'
|
---|
25 | }, 'math/always/'],
|
---|
26 | // Use legacy strictMath: true here to demonstrate it still works
|
---|
27 | [{strictMath: true, strictUnits: true, javascriptEnabled: true}, '../errors/eval/',
|
---|
28 | lessTester.testErrors, null],
|
---|
29 | [{strictMath: true, strictUnits: true, javascriptEnabled: true}, '../errors/parse/',
|
---|
30 | lessTester.testErrors, null],
|
---|
31 |
|
---|
32 | [{math: 'strict', strictUnits: true, javascriptEnabled: false}, 'no-js-errors/',
|
---|
33 | lessTester.testErrors, null],
|
---|
34 | [{math: 'strict', dumpLineNumbers: 'comments'}, 'debug/', null,
|
---|
35 | function(name) { return name + '-comments'; }],
|
---|
36 | [{math: 'strict', dumpLineNumbers: 'mediaquery'}, 'debug/', null,
|
---|
37 | function(name) { return name + '-mediaquery'; }],
|
---|
38 | [{math: 'strict', dumpLineNumbers: 'all'}, 'debug/', null,
|
---|
39 | function(name) { return name + '-all'; }],
|
---|
40 | // TODO: Change this to rewriteUrls: false once the relativeUrls option is removed
|
---|
41 | [{math: 'strict', relativeUrls: false, rootpath: 'folder (1)/'}, 'static-urls/'],
|
---|
42 | [{math: 'strict', compress: true}, 'compression/'],
|
---|
43 |
|
---|
44 | [{math: 0, strictUnits: true}, 'units/strict/'],
|
---|
45 | [{math: 0, strictUnits: false}, 'units/no-strict/'],
|
---|
46 |
|
---|
47 | [{math: 'strict', strictUnits: true, sourceMap: true, globalVars: true }, 'sourcemaps/',
|
---|
48 | lessTester.testSourcemap, null, null,
|
---|
49 | function(filename, type, baseFolder) {
|
---|
50 | if (type === 'vars') {
|
---|
51 | return path.join(baseFolder, filename) + '.json';
|
---|
52 | }
|
---|
53 | return path.join('test/sourcemaps', filename) + '.json';
|
---|
54 | }],
|
---|
55 |
|
---|
56 | [{math: 'strict', strictUnits: true, globalVars: true }, '_main/import/json/',
|
---|
57 | lessTester.testImports, null, true,
|
---|
58 | function(filename, type, baseFolder) {
|
---|
59 | return path.join(baseFolder, filename) + '.json';
|
---|
60 | }],
|
---|
61 | [{math: 'strict', strictUnits: true, sourceMap: {sourceMapFileInline: true}},
|
---|
62 | 'sourcemaps-empty/', lessTester.testEmptySourcemap],
|
---|
63 | [{math: 'strict', strictUnits: true, sourceMap: {disableSourcemapAnnotation: true}},
|
---|
64 | 'sourcemaps-disable-annotation/', lessTester.testSourcemapWithoutUrlAnnotation],
|
---|
65 | [{globalVars: true, banner: '/**\n * Test\n */\n'}, 'globalVars/',
|
---|
66 | null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
|
---|
67 | [{modifyVars: true}, 'modifyVars/',
|
---|
68 | null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
|
---|
69 | [{urlArgs: '424242'}, 'url-args/'],
|
---|
70 | [{rewriteUrls: 'all'}, 'rewrite-urls-all/'],
|
---|
71 | [{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
|
---|
72 | [{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
|
---|
73 | [{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'],
|
---|
74 | [{paths: ['data/', '_main/import/']}, 'include-path/'],
|
---|
75 | [{paths: 'data/'}, 'include-path-string/'],
|
---|
76 | [{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
|
---|
77 | [{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
|
---|
78 | [{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
|
---|
79 | [{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
|
---|
80 | [{math: 0}, '3rd-party/'],
|
---|
81 | [{ processImports: false }, 'process-imports/']
|
---|
82 | ];
|
---|
83 | testMap.forEach(function(args) {
|
---|
84 | lessTester.runTestSet.apply(lessTester, args)
|
---|
85 | });
|
---|
86 | lessTester.testSyncronous({syncImport: true}, '_main/import');
|
---|
87 | lessTester.testSyncronous({syncImport: true}, '_main/plugin');
|
---|
88 | lessTester.testSyncronous({syncImport: true}, 'math/strict/css');
|
---|
89 | lessTester.testNoOptions();
|
---|
90 | lessTester.testJSImport();
|
---|
91 | lessTester.finished();
|
---|
92 |
|
---|
93 | (() => {
|
---|
94 | // Create new tester, since tests are not independent and tests
|
---|
95 | // above modify tester in a way that breaks remote imports.
|
---|
96 | lessTester = lessTest();
|
---|
97 | var scope = nock('https://example.com')
|
---|
98 | .get('/redirect.less').query(true)
|
---|
99 | .reply(301, null, { location: '/target.less' })
|
---|
100 | .get('/target.less').query(true)
|
---|
101 | .reply(200);
|
---|
102 | lessTester.runTestSet(
|
---|
103 | {},
|
---|
104 | 'import-redirect/',
|
---|
105 | lessTester.testImportRedirect(scope)
|
---|
106 | );
|
---|
107 | lessTester.finished();
|
---|
108 | })();
|
---|