diff --git a/test/useable.test.js b/test/useable.test.js index 981da074..0e1a945d 100644 --- a/test/useable.test.js +++ b/test/useable.test.js @@ -8,30 +8,136 @@ var loaderUtils = require('loader-utils'); var useable = require("../useable"); describe("useable tests", function () { - var sandbox = sinon.sandbox.create(); - var getOptions; + describe('hmr', function () { + var sandbox = sinon.sandbox.create(); + var getOptions; - beforeEach(() => { - // Mock loaderUtils to override options - getOptions = sandbox.stub(loaderUtils, 'getOptions'); - }); + beforeEach(() => { + // Mock loaderUtils to override options + getOptions = sandbox.stub(loaderUtils, 'getOptions'); + }); - afterEach(() => { - sandbox.restore(); - }); + afterEach(() => { + sandbox.restore(); + }); - it("should output HMR code by default", function () { - assert.equal(/(module\.hot)/g.test(useable.pitch()), true); - }); + it("should output HMR code by default", function () { + assert.equal(/(module\.hot)/g.test(useable.pitch()), true); + }); - it("should NOT output HMR code when options.hmr is false", function () { - getOptions.returns({hmr: false}); - assert.equal(/(module\.hot)/g.test(useable.pitch()), false); + it("should NOT output HMR code when options.hmr is false", function () { + getOptions.returns({hmr: false}); + assert.equal(/(module\.hot)/g.test(useable.pitch()), false); + }); + + it("should output HMR code when options.hmr is true", function () { + getOptions.returns({hmr: true}); + assert.equal(/(module\.hot)/g.test(useable.pitch()), true); + }); }); - it("should output HMR code when options.hmr is true", function () { - getOptions.returns({hmr: true}); - assert.equal(/(module\.hot)/g.test(useable.pitch()), true); + describe('insert into', function () { + var path = require("path"); + + var utils = require("./utils"), + runCompilerTest = utils.runCompilerTest; + + var fs; + + var requiredCss = ".required { color: blue }", + requiredCssTwo = ".requiredTwo { color: cyan }", + localScopedCss = ":local(.className) { background: red; }", + localComposingCss = ` + :local(.composingClass) { + composes: className from './localScoped.css'; + color: blue; + } + `, + requiredStyle = ``, + existingStyle = ``, + checkValue = '
check
', + rootDir = path.resolve(__dirname + "/../") + "/", + jsdomHtml = [ + "", + "", + existingStyle, + "", + "", + "
", + checkValue, + "
", + "