diff --git a/test/index.js b/test/index.js index 1afa789..138c9cf 100644 --- a/test/index.js +++ b/test/index.js @@ -108,4 +108,26 @@ test('css-extract', function (t) { t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle') } }) + + t.test('should not extract dynamic insert-css statements, again', function (t) { + t.plan(4) + const sourcePath = path.join(__dirname, 'source-dynamic-2.js') + + browserify(sourcePath) + .plugin(cssExtract, { out: readCss }) + .bundle(readJs) + + function readCss () { + return bl(function (err, data) { + t.ifError(err, 'no error') + t.equal(String(data), '', 'no css extracted') + }) + } + + function readJs (err, data) { + t.ifError(err, 'no error') + const source = fs.readFileSync(sourcePath, 'utf8') + t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle') + } + }) }) diff --git a/test/source-dynamic-2.js b/test/source-dynamic-2.js new file mode 100644 index 0000000..fd696d4 --- /dev/null +++ b/test/source-dynamic-2.js @@ -0,0 +1,7 @@ +var insertCss = require('insert-css') + +insert('.foo {}') + +function insert (foo) { + insertCss(foo) +}