|
1 | | -//const assertDiff = require('assert-diff'); |
| 1 | +const assertDiff = require('assert-diff'); |
2 | 2 | const fse = require('fs-extra'); |
3 | | -//const path = require('path'); |
4 | | -//const Migrator = require('../../../lib/migrator'); |
| 3 | +const fixturify = require('fixturify'); |
| 4 | +const path = require('path'); |
| 5 | +const Migrator = require('../../../lib/migrator'); |
| 6 | +const { setupConsole, resetConsole } = require('../../helpers'); |
5 | 7 |
|
6 | | -//assertDiff.options.strict = true; |
| 8 | +assertDiff.options.strict = true; |
7 | 9 |
|
8 | 10 | describe('structure = nested', function () { |
9 | 11 | beforeEach(function () { |
10 | 12 | this.tmpPath = 'tmp/process-files'; |
11 | 13 | fse.mkdirsSync(this.tmpPath); |
| 14 | + setupConsole(); |
12 | 15 | }); |
13 | 16 |
|
14 | 17 | afterEach(function () { |
15 | 18 | fse.removeSync(this.tmpPath); |
| 19 | + resetConsole(); |
16 | 20 | }); |
17 | 21 |
|
18 | | - // describe('For an app with component classes written in JavaScript', function() { |
19 | | - // beforeEach(function() { |
20 | | - // const fixturePath = path.resolve(__dirname, '../../fixtures/app/example-js'); |
| 22 | + describe('For an app with component classes written in JavaScript', function () { |
| 23 | + beforeEach(function () { |
| 24 | + const fixturePath = path.resolve(__dirname, '../../fixtures/app/example-js'); |
21 | 25 |
|
22 | | - // // Find input and output files |
23 | | - // const input = require(`${fixturePath}/input`); |
24 | | - // this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
| 26 | + // Find input and output files |
| 27 | + const input = require(`${fixturePath}/input`); |
| 28 | + this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
25 | 29 |
|
26 | | - // // Copy the input file to the temporary folder |
27 | | - // fixturify.writeSync(this.tmpPath, input); |
| 30 | + // Copy the input file to the temporary folder |
| 31 | + fixturify.writeSync(this.tmpPath, input); |
28 | 32 |
|
29 | | - // // Create an instance of the Migrator class |
30 | | - // this.migrator = new Migrator({ |
31 | | - // projectRoot: this.tmpPath, |
32 | | - // structure: 'nested' |
33 | | - // }); |
34 | | - // }); |
| 33 | + // Create an instance of the Migrator class |
| 34 | + this.migrator = new Migrator({ |
| 35 | + projectRoot: this.tmpPath, |
| 36 | + structure: 'nested', |
| 37 | + }); |
| 38 | + }); |
35 | 39 |
|
36 | | - // it('Codemod works as expected', async function() { |
37 | | - // await this.migrator.execute(); |
| 40 | + it('Codemod works as expected', async function () { |
| 41 | + await this.migrator.execute(); |
38 | 42 |
|
39 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 43 | + const actualOutput = fixturify.readSync(this.tmpPath); |
40 | 44 |
|
41 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
42 | | - // }); |
| 45 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 46 | + }); |
43 | 47 |
|
44 | | - // it('Codemod is idempotent', async function() { |
45 | | - // await this.migrator.execute(); |
46 | | - // await this.migrator.execute(); |
| 48 | + it('Codemod is idempotent', async function () { |
| 49 | + await this.migrator.execute(); |
| 50 | + await this.migrator.execute(); |
47 | 51 |
|
48 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 52 | + const actualOutput = fixturify.readSync(this.tmpPath); |
49 | 53 |
|
50 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
51 | | - // }); |
52 | | - // }); |
| 54 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 55 | + }); |
| 56 | + }); |
53 | 57 |
|
54 | | - // describe('For an app with component classes written in TypeScript', function() { |
55 | | - // beforeEach(function() { |
56 | | - // const fixturePath = path.resolve(__dirname, '../../fixtures/app/example-ts'); |
| 58 | + describe('For an app with component classes written in TypeScript', function () { |
| 59 | + beforeEach(function () { |
| 60 | + const fixturePath = path.resolve(__dirname, '../../fixtures/app/example-ts'); |
57 | 61 |
|
58 | | - // // Find input and output files |
59 | | - // const input = require(`${fixturePath}/input`); |
60 | | - // this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
| 62 | + // Find input and output files |
| 63 | + const input = require(`${fixturePath}/input`); |
| 64 | + this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
61 | 65 |
|
62 | | - // // Copy the input file to the temporary folder |
63 | | - // fixturify.writeSync(this.tmpPath, input); |
| 66 | + // Copy the input file to the temporary folder |
| 67 | + fixturify.writeSync(this.tmpPath, input); |
64 | 68 |
|
65 | | - // // Create an instance of the Migrator class |
66 | | - // this.migrator = new Migrator({ |
67 | | - // projectRoot: this.tmpPath, |
68 | | - // structure: 'nested' |
69 | | - // }); |
70 | | - // }); |
| 69 | + // Create an instance of the Migrator class |
| 70 | + this.migrator = new Migrator({ |
| 71 | + projectRoot: this.tmpPath, |
| 72 | + structure: 'nested', |
| 73 | + }); |
| 74 | + }); |
71 | 75 |
|
72 | | - // it('Codemod works as expected', async function() { |
73 | | - // await this.migrator.execute(); |
| 76 | + it('Codemod works as expected', async function () { |
| 77 | + await this.migrator.execute(); |
74 | 78 |
|
75 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 79 | + const actualOutput = fixturify.readSync(this.tmpPath); |
76 | 80 |
|
77 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
78 | | - // }); |
| 81 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 82 | + }); |
79 | 83 |
|
80 | | - // it('Codemod is idempotent', async function() { |
81 | | - // await this.migrator.execute(); |
82 | | - // await this.migrator.execute(); |
| 84 | + it('Codemod is idempotent', async function () { |
| 85 | + await this.migrator.execute(); |
| 86 | + await this.migrator.execute(); |
83 | 87 |
|
84 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 88 | + const actualOutput = fixturify.readSync(this.tmpPath); |
85 | 89 |
|
86 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
87 | | - // }); |
88 | | - // }); |
| 90 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 91 | + }); |
| 92 | + }); |
89 | 93 |
|
90 | | - // describe('For an addon with component classes written in JavaScript', function() { |
91 | | - // beforeEach(function() { |
92 | | - // const fixturePath = path.resolve(__dirname, '../../fixtures/addon/example-js'); |
| 94 | + describe('For an addon with component classes written in JavaScript', function () { |
| 95 | + beforeEach(function () { |
| 96 | + const fixturePath = path.resolve(__dirname, '../../fixtures/addon/example-js'); |
93 | 97 |
|
94 | | - // // Find input and output files |
95 | | - // const input = require(`${fixturePath}/input`); |
96 | | - // this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
| 98 | + // Find input and output files |
| 99 | + const input = require(`${fixturePath}/input`); |
| 100 | + this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
97 | 101 |
|
98 | | - // // Copy the input file to the temporary folder |
99 | | - // fixturify.writeSync(this.tmpPath, input); |
| 102 | + // Copy the input file to the temporary folder |
| 103 | + fixturify.writeSync(this.tmpPath, input); |
100 | 104 |
|
101 | | - // // Create an instance of the Migrator class |
102 | | - // this.migrator = new Migrator({ |
103 | | - // projectRoot: this.tmpPath, |
104 | | - // structure: 'nested' |
105 | | - // }); |
106 | | - // }); |
| 105 | + // Create an instance of the Migrator class |
| 106 | + this.migrator = new Migrator({ |
| 107 | + projectRoot: this.tmpPath, |
| 108 | + structure: 'nested', |
| 109 | + }); |
| 110 | + }); |
107 | 111 |
|
108 | | - // it('Codemod works as expected', async function() { |
109 | | - // await this.migrator.execute(); |
| 112 | + it('Codemod works as expected', async function () { |
| 113 | + await this.migrator.execute(); |
110 | 114 |
|
111 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 115 | + const actualOutput = fixturify.readSync(this.tmpPath); |
112 | 116 |
|
113 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
114 | | - // }); |
| 117 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 118 | + }); |
115 | 119 |
|
116 | | - // it('Codemod is idempotent', async function() { |
117 | | - // await this.migrator.execute(); |
118 | | - // await this.migrator.execute(); |
| 120 | + it('Codemod is idempotent', async function () { |
| 121 | + await this.migrator.execute(); |
| 122 | + await this.migrator.execute(); |
119 | 123 |
|
120 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 124 | + const actualOutput = fixturify.readSync(this.tmpPath); |
121 | 125 |
|
122 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
123 | | - // }); |
124 | | - // }); |
| 126 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 127 | + }); |
| 128 | + }); |
125 | 129 |
|
126 | | - // describe('For an addon with component classes written in TypeScript', function() { |
127 | | - // beforeEach(function() { |
128 | | - // const fixturePath = path.resolve(__dirname, '../../fixtures/addon/example-ts'); |
| 130 | + describe('For an addon with component classes written in TypeScript', function () { |
| 131 | + beforeEach(function () { |
| 132 | + const fixturePath = path.resolve(__dirname, '../../fixtures/addon/example-ts'); |
129 | 133 |
|
130 | | - // // Find input and output files |
131 | | - // const input = require(`${fixturePath}/input`); |
132 | | - // this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
| 134 | + // Find input and output files |
| 135 | + const input = require(`${fixturePath}/input`); |
| 136 | + this.expectedOutput = require(`${fixturePath}/classic-to-nested`); |
133 | 137 |
|
134 | | - // // Copy the input file to the temporary folder |
135 | | - // fixturify.writeSync(this.tmpPath, input); |
| 138 | + // Copy the input file to the temporary folder |
| 139 | + fixturify.writeSync(this.tmpPath, input); |
136 | 140 |
|
137 | | - // // Create an instance of the Migrator class |
138 | | - // this.migrator = new Migrator({ |
139 | | - // projectRoot: this.tmpPath, |
140 | | - // structure: 'nested' |
141 | | - // }); |
142 | | - // }); |
| 141 | + // Create an instance of the Migrator class |
| 142 | + this.migrator = new Migrator({ |
| 143 | + projectRoot: this.tmpPath, |
| 144 | + structure: 'nested', |
| 145 | + }); |
| 146 | + }); |
143 | 147 |
|
144 | | - // it('Codemod works as expected', async function() { |
145 | | - // await this.migrator.execute(); |
| 148 | + it('Codemod works as expected', async function () { |
| 149 | + await this.migrator.execute(); |
146 | 150 |
|
147 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 151 | + const actualOutput = fixturify.readSync(this.tmpPath); |
148 | 152 |
|
149 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
150 | | - // }); |
| 153 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 154 | + }); |
151 | 155 |
|
152 | | - // it('Codemod is idempotent', async function() { |
153 | | - // await this.migrator.execute(); |
154 | | - // await this.migrator.execute(); |
| 156 | + it('Codemod is idempotent', async function () { |
| 157 | + await this.migrator.execute(); |
| 158 | + await this.migrator.execute(); |
155 | 159 |
|
156 | | - // const actualOutput = fixturify.readSync(this.tmpPath); |
| 160 | + const actualOutput = fixturify.readSync(this.tmpPath); |
157 | 161 |
|
158 | | - // assertDiff.deepEqual(actualOutput, this.expectedOutput); |
159 | | - // }); |
160 | | - // }); |
| 162 | + assertDiff.deepEqual(actualOutput, this.expectedOutput); |
| 163 | + }); |
| 164 | + }); |
161 | 165 | }); |
0 commit comments