Skip to content

Commit

Permalink
refactor: improve naming of test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Mar 17, 2017
1 parent 01ab011 commit 7ccfa43
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions test/helpers/createSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const cssFixturesPath = path.resolve(fixturesPath, 'css');
const matchWebpackImports = /(@import\s+(\([^)]+\))?\s*["'])~/g;
const lessBin = require.resolve('.bin/lessc');
const ignore = [
'non-less-import',
'import-non-less',
'error-import-not-existing',
'error-mixed-resolvers',
];
Expand All @@ -23,8 +23,8 @@ const ignore = [
* The object keys are the test ids.
*/
const tildeReplacements = {
imports: '../node_modules/',
'imports-node': '../node_modules/',
import: '../node_modules/',
'import-webpack': '../node_modules/',
'source-map': '../node_modules/',
};
// Maps test ids on cli arguments
Expand All @@ -34,7 +34,7 @@ const lessOptions = {
`--source-map-basepath=${projectPath}`,
`--source-map-rootpath=${projectPath}`,
],
'imports-paths': [
'import-paths': [
`--include-path=${path.resolve(fixturesPath, 'node_modules')}`,
],
};
Expand Down
18 changes: 9 additions & 9 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,36 @@ test('should compile simple less without errors', async () => {
});

test('should resolve all imports', async () => {
await compileAndCompare('imports');
await compileAndCompare('import');
});

test('should resolve all imports from node_modules', async () => {
await compileAndCompare('imports-node');
test('should resolve all imports from node_modules using webpack\'s resolver', async () => {
await compileAndCompare('import-webpack');
});

test('should resolve imports from given paths', async () => {
await compileAndCompare('imports-paths', { paths: [__dirname, nodeModulesPath] });
test('should resolve all imports from the given paths using Less\' resolver', async () => {
await compileAndCompare('import-paths', { paths: [__dirname, nodeModulesPath] });
});

test('should allow to disable webpack\'s resolver by passing an empty paths array', async () => {
const err = await compile('imports-node', moduleRules.basic({ paths: [] }))
const err = await compile('import-webpack', moduleRules.basic({ paths: [] }))
.catch(e => e);

expect(err).toBeInstanceOf(Error);
expect(err.message).toMatch(/'~some\/css\.css' wasn't found/);
});

test('should not try to resolve import urls', async () => {
await compileAndCompare('imports-url');
await compileAndCompare('import-url');
});

test('should allow non-less-import', async () => {
test('should allow to import non-less files', async () => {
let inspect;
const rules = moduleRules.nonLessImport((i) => {
inspect = i;
});

await compile('non-less-import', rules);
await compile('import-non-less', rules);

const [css] = inspect.arguments;

Expand Down

0 comments on commit 7ccfa43

Please # to comment.