Skip to content

Commit

Permalink
Merge pull request #86 from billybonks/enhancement/add-name-to-spec
Browse files Browse the repository at this point in the history
Enhancement/add name to spec
  • Loading branch information
billybonks authored Jul 5, 2018
2 parents a6cff2f + 2a3ebbc commit a3337ac
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion lib/test-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(relativePath, results, testingFramework){
assertions = results.warnings.map(warning => `${warning.line}:${warning.column} ${escapeString(warning.text)}`).join('\n');
}
return (
generator.suiteHeader('Stylelint') +
generator.suiteHeader(`Stylelint: ${relativePath}`) +
generator.test(relativePath + ' should pass stylelint', passed, assertions) +
generator.suiteFooter()
);
Expand Down
40 changes: 40 additions & 0 deletions tests/__snapshots__/test-generator-test.js.snap
Original file line number Diff line number Diff line change
@@ -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');
});
"
`;
4 changes: 2 additions & 2 deletions tests/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
@@ -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)');
Expand All @@ -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');
Expand Down
44 changes: 2 additions & 42 deletions tests/test-generator-test.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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();
});
});
});
Expand Down

0 comments on commit a3337ac

Please sign in to comment.