|
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 |
| 39 | + let(:typescript_enabled?) { args.include?('--typescript') } |
48 | 40 |
|
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 |
63 | | - |
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 |
|
0 commit comments