|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | 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'); |
4 | 8 |
|
5 | | -const defineTest = require('jscodeshift/dist/testUtils').defineTest; |
6 | 9 | const fixtureFolder = `${__dirname}/../__testfixtures__/ember-qunit-codemod`; |
7 | 10 |
|
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