@@ -10,50 +10,51 @@ var Migrator = require('../lib/migrator');
1010assertDiff . options . strict = true ;
1111
1212describe ( "Migrator" , function ( ) {
13- var tmpPath = "tmp/process-files" ;
14- var fixturesPath = path . resolve ( __dirname , "fixtures" ) ;
13+ describe ( 'newComponentStructure = flat' , function ( ) {
14+ var tmpPath = "tmp/process-files" ;
15+ var fixturesPath = path . resolve ( __dirname , "fixtures/classic-to-flat" ) ;
1516
16- beforeEach ( function ( ) {
17- fse . mkdirsSync ( tmpPath ) ;
18- } ) ;
17+ beforeEach ( function ( ) {
18+ fse . mkdirsSync ( tmpPath ) ;
19+ } ) ;
1920
20- afterEach ( function ( ) {
21- fse . removeSync ( tmpPath ) ;
22- } ) ;
21+ afterEach ( function ( ) {
22+ fse . removeSync ( tmpPath ) ;
23+ } ) ;
2324
24- var entries = fse . readdirSync ( fixturesPath ) ;
25-
26- entries . forEach ( async function ( entry ) {
27- it ( `should migrate ${ entry } fixture properly` , async function ( ) {
28- var fixturePath = path . join ( fixturesPath , entry ) ;
29- var input = require ( fixturePath + "/input" ) ;
30- var expected = require ( fixturePath + "/output" ) ;
31- var migratorConfig = { } ;
32- try {
33- migratorConfig = require ( fixturePath + "/config" ) ;
34- } catch ( e ) {
35- // fixture uses default config...
36- }
37-
38- fixturify . writeSync ( tmpPath , input ) ;
39-
40- var migratorOptions = Object . assign (
41- {
42- projectRoot : tmpPath ,
43- newComponentStructure : 'flat'
44- } ,
45- migratorConfig
46- ) ;
47-
48- var migrator = new Migrator ( migratorOptions ) ;
49- await migrator . execute ( ) ;
50-
51- var actual = fixturify . readSync ( tmpPath ) ;
52- assertDiff . deepEqual ( actual , expected , "the codemod should work as expected" ) ;
53-
54- await migrator . execute ( ) ;
55- assertDiff . deepEqual ( actual , expected , "the codemod should be idempotent" ) ;
25+ var entries = fse . readdirSync ( fixturesPath ) ;
26+
27+ entries . forEach ( async function ( entry ) {
28+ it ( `should migrate ${ entry } fixture properly` , async function ( ) {
29+ var fixturePath = path . join ( fixturesPath , entry ) ;
30+ var input = require ( fixturePath + "/input" ) ;
31+ var expected = require ( fixturePath + "/output" ) ;
32+ var migratorConfig = { } ;
33+ try {
34+ migratorConfig = require ( fixturePath + "/config" ) ;
35+ } catch ( e ) {
36+ // fixture uses default config...
37+ }
38+
39+ fixturify . writeSync ( tmpPath , input ) ;
40+
41+ var migratorOptions = Object . assign (
42+ {
43+ projectRoot : tmpPath ,
44+ newComponentStructure : 'flat'
45+ } ,
46+ migratorConfig
47+ ) ;
48+
49+ var migrator = new Migrator ( migratorOptions ) ;
50+ await migrator . execute ( ) ;
51+
52+ var actual = fixturify . readSync ( tmpPath ) ;
53+ assertDiff . deepEqual ( actual , expected , "the codemod should work as expected" ) ;
54+
55+ await migrator . execute ( ) ;
56+ assertDiff . deepEqual ( actual , expected , "the codemod should be idempotent" ) ;
57+ } ) ;
5658 } ) ;
5759 } ) ;
58- } ) ;
59-
60+ } ) ;
0 commit comments