Skip to content

Commit

Permalink
Integration test added
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrognomik committed Apr 15, 2021
1 parent b895739 commit 08f106c
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"modules": true,
"plugins": {
"postcss-modules": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.foo {
color: #fff;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const map = require('./foo.css');

module.exports = {
foo: map.foo,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: blue;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require('./index.css');
var foo = require('./foo');

module.exports = function () {
return foo.foo;
};
Empty file.
28 changes: 28 additions & 0 deletions packages/core/integration-tests/test/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,34 @@ describe('postcss', () => {
assert(css.includes(`.${cssClass}`));
});

it('should build successfully with only postcss-modules config', async () => {
let b = await bundle(
path.join(__dirname, '/integration/postcss-modules-config/index.js'),
);

assertBundles(b, [
{
name: 'index.js',
assets: ['foo.css', 'foo.js', 'index.css', 'index.js'],
},
{
name: 'index.css',
assets: ['foo.css', 'index.css'],
},
]);

let output = await run(b);
assert.equal(typeof output, 'function');

let value = output();
assert(/_foo_[0-9a-z]/.test(value));

let cssClass = value.match(/(_foo_[0-9a-z])/)[1];

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
assert(css.includes(`.${cssClass}`));
});

it('should support transforming css modules with postcss (import default)', async () => {
let b = await bundle(
path.join(
Expand Down

0 comments on commit 08f106c

Please sign in to comment.