Skip to content

Commit 5d73528

Browse files
author
Robert Jackson
committed
Setup test suite to confirm idempotent.
1 parent 922821b commit 5d73528

2 files changed

Lines changed: 42 additions & 12 deletions

File tree

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ module.exports = {
1717
printWidth: 100,
1818
}],
1919
},
20+
overrides: [
21+
{
22+
files: ['__tests__/**/*.js'],
23+
env: {
24+
jest: true
25+
}
26+
},
27+
],
2028
};
Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
11
'use strict';
22

33
const fs = require('fs');
4+
const path = require('path');
5+
6+
const runInlineTest = require('jscodeshift/dist/testUtils').runInlineTest;
7+
const EmberQUnitTransform = require('../ember-qunit-codemod');
48

5-
const defineTest = require('jscodeshift/dist/testUtils').defineTest;
69
const fixtureFolder = `${__dirname}/../__testfixtures__/ember-qunit-codemod`;
710

8-
fs
9-
.readdirSync(fixtureFolder)
10-
.filter(filename => /\.input\.js$/.test(filename))
11-
.forEach(filename => {
12-
defineTest(
13-
__dirname,
14-
'ember-qunit-codemod',
15-
{},
16-
`ember-qunit-codemod/${filename.replace(/\.input\.js$/, '')}`
17-
);
18-
});
11+
describe('ember-qunit-codemod', function() {
12+
fs
13+
.readdirSync(fixtureFolder)
14+
.filter(filename => /\.input\.js$/.test(filename))
15+
.forEach(filename => {
16+
let testName = filename.replace('.input.js', '');
17+
let inputPath = path.join(fixtureFolder, `${testName}.input.js`);
18+
let outputPath = path.join(fixtureFolder, `${testName}.output.js`);
19+
20+
describe(testName, function() {
21+
it('transforms correctly', function() {
22+
runInlineTest(
23+
EmberQUnitTransform,
24+
{},
25+
{ source: fs.readFileSync(inputPath, 'utf8') },
26+
fs.readFileSync(outputPath, 'utf8')
27+
);
28+
});
29+
30+
it('is idempotent', function() {
31+
runInlineTest(
32+
EmberQUnitTransform,
33+
{},
34+
{ source: fs.readFileSync(outputPath, 'utf8') },
35+
fs.readFileSync(outputPath, 'utf8')
36+
);
37+
});
38+
});
39+
});
40+
});

0 commit comments

Comments
 (0)