|
32 | 32 | let(:ext) { 'ts' }
|
33 | 33 |
|
34 | 34 | include_context 'assert framework structure'
|
35 |
| - include_context 'assert application.js entrypoint renaming' |
36 | 35 | end
|
37 | 36 | end
|
38 | 37 |
|
39 | 38 | shared_context 'assert application.js entrypoint renaming' do
|
40 |
| - context 'when application.js exists' do |
41 |
| - before do |
42 |
| - FileUtils.mkdir_p(File.join(destination_root, 'app/frontend/entrypoints')) |
43 |
| - File.write(File.join(destination_root, 'app/frontend/entrypoints/application.js'), '// Application JS') |
44 |
| - end |
45 |
| - |
46 |
| - it 'renames application.js to application.ts when TypeScript is enabled' do |
47 |
| - expect { generator }.not_to raise_error |
48 |
| - |
49 |
| - if ext == 'ts' |
50 |
| - expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.ts'))).to be true |
51 |
| - expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.js'))).to be false |
52 |
| - else |
53 |
| - expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.js'))).to be true |
54 |
| - expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.ts'))).to be false |
55 |
| - end |
56 |
| - end |
57 |
| - end |
58 |
| - |
59 |
| - context 'when application.js does not exist' do |
60 |
| - before do |
61 |
| - FileUtils.rm_f(File.join(destination_root, 'app/frontend/entrypoints/application.js')) |
62 |
| - end |
| 39 | + let(:typescript_enabled?) { args.include?('--typescript') } |
63 | 40 |
|
64 |
| - it 'does not attempt to rename when TypeScript is enabled' do |
65 |
| - expect { generator }.not_to raise_error |
| 41 | + it 'renames application.js to application.ts if TypeScript flag is enabled' do |
| 42 | + expect { generator }.not_to raise_error |
66 | 43 |
|
| 44 | + if typescript_enabled? |
| 45 | + expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.ts'))).to be true |
| 46 | + expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.js'))).to be false |
| 47 | + else |
| 48 | + expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.js'))).to be true |
67 | 49 | expect(File.exist?(File.join(destination_root, 'app/frontend/entrypoints/application.ts'))).to be false
|
68 | 50 | end
|
69 | 51 | end
|
|
91 | 73 | end
|
92 | 74 | end)
|
93 | 75 | end
|
| 76 | + |
| 77 | + include_context 'assert application.js entrypoint renaming' |
| 78 | + |
| 79 | + context 'with --typescript' do |
| 80 | + let(:args) { super() + %w[--typescript] } |
| 81 | + |
| 82 | + include_context 'assert application.js entrypoint renaming' |
| 83 | + end |
94 | 84 | end
|
95 | 85 | end
|
96 | 86 |
|
|
115 | 105 | let(:ext) { 'ts' }
|
116 | 106 |
|
117 | 107 | include_context 'assert framework structure'
|
118 |
| - include_context 'assert application.js entrypoint renaming' |
119 | 108 |
|
120 | 109 | context 'with old Inertia version' do
|
121 | 110 | let(:inertia_version) { '1.2.0' }
|
|
136 | 125 | let(:ext) { 'ts' }
|
137 | 126 |
|
138 | 127 | include_context 'assert framework structure'
|
139 |
| - include_context 'assert application.js entrypoint renaming' |
140 | 128 |
|
141 | 129 | context 'with old Inertia version' do
|
142 | 130 | let(:inertia_version) { '1.2.0' }
|
|
0 commit comments