Skip to content

Commit

Permalink
test: more
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito committed Sep 28, 2020
1 parent 733cea6 commit 5bb8640
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/import-glob-alias.styl
@@ -1 +1 @@
@import '~globAlias/*'
@import '~globSimpleAlias/*'
1 change: 1 addition & 0 deletions test/helpers/getCodeFromStylus.js
Expand Up @@ -14,6 +14,7 @@ const pathMap = {
'alias/1': path.resolve(fixturesDir, 'alias', '1.styl'),
'~alias/2': path.resolve(fixturesDir, 'alias', '2.styl'),
'globAlias/*': path.resolve(fixturesDir, 'glob-webpack/*'),
'~globSimpleAlias/*': path.resolve(fixturesDir, 'glob/*'),
fakenib: path.resolve(fixturesDir, 'node_modules', 'fakenib', 'index.styl'),
'~fakenib': path.resolve(
fixturesDir,
Expand Down
Empty file removed test/import-dir-like-a-glob.styl
Empty file.
13 changes: 12 additions & 1 deletion test/loader.test.js
Expand Up @@ -124,7 +124,13 @@ describe('loader', () => {
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
use: plugin(),
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(codeFromBundle.css).toMatchSnapshot('css');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
Expand Down Expand Up @@ -161,7 +167,10 @@ describe('loader', () => {
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
// const codeFromStylus = await getCodeFromStylus(testId);

// Stylus url-resolver does not work with loader inline syntax
// expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(codeFromBundle.css).toMatchSnapshot('css');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
Expand Down Expand Up @@ -1147,14 +1156,16 @@ describe('loader', () => {
{
resolve: {
alias: {
globAlias: path.resolve(__dirname, 'fixtures', 'glob'),
globSimpleAlias: path.resolve(__dirname, 'fixtures', 'glob'),
},
},
}
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const codeFromStylus = await getCodeFromStylus(testId);

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(codeFromBundle.css).toMatchSnapshot('css');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
Expand Down
39 changes: 39 additions & 0 deletions test/sourceMap-options.test.js
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs';
import {
compile,
getCodeFromBundle,
getCodeFromStylus,
getCompiler,
getErrors,
getWarnings,
Expand Down Expand Up @@ -33,6 +34,13 @@ describe('"sourceMap" options', () => {
.replace(/\\/g, '/');
});

const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
paths: ['test/fixtures/paths'],
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(css).toMatchSnapshot('css');
expect(map).toMatchSnapshot('source map');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
Expand Down Expand Up @@ -67,6 +75,13 @@ describe('"sourceMap" options', () => {
.replace(/\\/g, '/');
});

const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
paths: ['test/fixtures/paths'],
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(css).toMatchSnapshot('css');
expect(map).toMatchSnapshot('source map');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
Expand Down Expand Up @@ -101,7 +116,13 @@ describe('"sourceMap" options', () => {
.relative(path.resolve(__dirname, '..'), source)
.replace(/\\/g, '/');
});
const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
paths: ['test/fixtures/paths'],
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(css).toMatchSnapshot('css');
expect(map).toMatchSnapshot('source map');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
Expand All @@ -119,7 +140,13 @@ describe('"sourceMap" options', () => {
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const { css, map } = codeFromBundle;
const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
paths: ['test/fixtures/paths'],
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(css).toMatchSnapshot('css');
expect(map).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot('warnings');
Expand All @@ -142,7 +169,13 @@ describe('"sourceMap" options', () => {
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const { css, map } = codeFromBundle;
const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
paths: ['test/fixtures/paths'],
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(css).toMatchSnapshot('css');
expect(map).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot('warnings');
Expand All @@ -166,7 +199,13 @@ describe('"sourceMap" options', () => {
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const { css, map } = codeFromBundle;
const codeFromStylus = await getCodeFromStylus(testId, {
stylusOptions: {
paths: ['test/fixtures/paths'],
},
});

expect(codeFromBundle.css).toBe(codeFromStylus.css);
expect(css).toMatchSnapshot('css');
expect(map).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot('warnings');
Expand Down

0 comments on commit 5bb8640

Please sign in to comment.