diff --git a/tests/__snapshots__/test-generator-test.js.snap b/tests/__snapshots__/test-generator-test.js.snap new file mode 100644 index 0000000..29f4e0c --- /dev/null +++ b/tests/__snapshots__/test-generator-test.js.snap @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test-generator errors is defined mocha generates correct errored test 1`] = ` +"describe('Stylelint: has-errors.scss', function() { + it('has-errors.scss should pass stylelint', function() { + // test failed + var error = new chai.AssertionError('1:15 Unexpected empty block (block-no-empty)\\\\n6:10 Expected \\\\\\\\\\"#000000\\\\\\\\\\" to be \\\\\\\\\\"black\\\\\\\\\\" (color-named)'); + error.stack = undefined; + throw error; + }); +}); +" +`; + +exports[`test-generator errors is defined mocha generates correct passed test 1`] = ` +"describe('Stylelint: no-errors.scss', function() { + it('no-errors.scss should pass stylelint', function() { + // test passed + }); +}); +" +`; + +exports[`test-generator errors is defined qunit generates correct errored test 1`] = ` +"QUnit.module('Stylelint: has-errors.scss'); +QUnit.test('has-errors.scss should pass stylelint', function(assert) { + assert.expect(1); + assert.ok(false, '1:15 Unexpected empty block (block-no-empty)\\\\n6:10 Expected \\\\\\\\\\"#000000\\\\\\\\\\" to be \\\\\\\\\\"black\\\\\\\\\\" (color-named)'); +}); +" +`; + +exports[`test-generator errors is defined qunit generates correct passed test 1`] = ` +"QUnit.module('Stylelint: no-errors.scss'); +QUnit.test('no-errors.scss should pass stylelint', function(assert) { + assert.expect(1); + assert.ok(true, 'no-errors.scss should pass stylelint'); +}); +" +`; diff --git a/tests/__snapshots__/test.js.snap b/tests/__snapshots__/test.js.snap index 18de27e..317b4d9 100644 --- a/tests/__snapshots__/test.js.snap +++ b/tests/__snapshots__/test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Broccoli StyleLint Plugin Generated Tests generates correct failing test string 1`] = ` -"QUnit.module('Stylelint'); +"QUnit.module('Stylelint: has-errors.scss'); QUnit.test('has-errors.scss should pass stylelint', function(assert) { assert.expect(1); assert.ok(false, '1:15 Unexpected empty block (block-no-empty)\\\\n6:10 Expected \\\\\\\\\\"#000000\\\\\\\\\\" to be \\\\\\\\\\"black\\\\\\\\\\" (color-named)'); @@ -10,7 +10,7 @@ QUnit.test('has-errors.scss should pass stylelint', function(assert) { `; exports[`Broccoli StyleLint Plugin Generated Tests generates correct passing test string 1`] = ` -"QUnit.module('Stylelint'); +"QUnit.module('Stylelint: no-errors.scss'); QUnit.test('no-errors.scss should pass stylelint', function(assert) { assert.expect(1); assert.ok(true, 'no-errors.scss should pass stylelint'); diff --git a/tests/test-generator-test.js b/tests/test-generator-test.js index 7439991..be8210a 100644 --- a/tests/test-generator-test.js +++ b/tests/test-generator-test.js @@ -1,44 +1,4 @@ 'use strict'; - -/* eslint-disable no-useless-escape*/ -let outputs ={ - qunit: { - errored: -`QUnit.module('Stylelint'); -QUnit.test('has-errors.scss should pass stylelint', function(assert) { - assert.expect(1); - assert.ok(false, '1:15 Unexpected empty block (block-no-empty)\\n6:10 Expected \\\\\"#000000\\\\\" to be \\\\\"black\\\\\" (color-named)'); -}); -`, - passed: -`QUnit.module('Stylelint'); -QUnit.test('no-errors.scss should pass stylelint', function(assert) { - assert.expect(1); - assert.ok(true, 'no-errors.scss should pass stylelint'); -}); -` -}, - mocha: { - errored: -`describe('Stylelint', function() { - it('has-errors.scss should pass stylelint', function() { - // test failed - var error = new chai.AssertionError('1:15 Unexpected empty block (block-no-empty)\\n6:10 Expected \\\\\"#000000\\\\\" to be \\\\\"black\\\\\" (color-named)'); - error.stack = undefined; - throw error; - }); -}); -`, - passed: -`describe('Stylelint', function() { - it('no-errors.scss should pass stylelint', function() { - // test passed - }); -}); -` - } -}; - const frameworks = ['qunit', 'mocha']; const generator = require('../lib/test-generator'); const errors = require('./fixtures/errors'); @@ -50,11 +10,11 @@ describe('test-generator', function() { describe(framework, function() { it('generates correct errored test', function(){ let results = generator('has-errors.scss', errors, framework); - expect(results).toEqual(outputs[framework].errored); + expect(results).toMatchSnapshot(); }); it('generates correct passed test', function(){ let results = generator('no-errors.scss', noErrors, framework); - expect(results).toEqual(outputs[framework].passed); + expect(results).toMatchSnapshot(); }); }); });