|
| 1 | +const shell = require('shelljs'); |
| 2 | + |
| 3 | +const util = require('../util'); |
| 4 | + |
| 5 | +shell.config.silent = false; |
| 6 | + |
| 7 | +const testDir = 'integration'; |
| 8 | +const fixtureName = 'build-withBabel'; |
| 9 | +const stageName = `stage-integration-${fixtureName}`; |
| 10 | + |
| 11 | +describe('integration :: tsdx build :: .babelrc.js', () => { |
| 12 | + beforeAll(() => { |
| 13 | + util.teardownStage(stageName); |
| 14 | + util.setupStageWithFixture(testDir, stageName, fixtureName); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should convert styled-components template tags', () => { |
| 18 | + let output = shell.exec('node ../dist/index.js build'); |
| 19 | + expect(output.code).toBe(0); |
| 20 | + |
| 21 | + // from styled.h1` to styled.h1( |
| 22 | + output = shell.grep(/styled.h1\(/, ['dist/build-withbabel.*.js']); |
| 23 | + expect(output.code).toBe(0); |
| 24 | + }); |
| 25 | + |
| 26 | + // TODO: make this test work by allowing customization of plugin order |
| 27 | + it.skip('should remove comments in the CSS', () => { |
| 28 | + // the "should be removed" comment shouldn't be there (gets error code) |
| 29 | + const output = shell.grep(/should be removed/, [ |
| 30 | + 'dist/build-withbabel.*.js', |
| 31 | + ]); |
| 32 | + expect(output.code).toBe(1); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should compile files into a dist directory', () => { |
| 36 | + expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); |
| 37 | + expect( |
| 38 | + shell.test('-f', 'dist/build-withbabel.cjs.development.js') |
| 39 | + ).toBeTruthy(); |
| 40 | + expect( |
| 41 | + shell.test('-f', 'dist/build-withbabel.cjs.production.min.js') |
| 42 | + ).toBeTruthy(); |
| 43 | + expect(shell.test('-f', 'dist/build-withbabel.esm.js')).toBeTruthy(); |
| 44 | + |
| 45 | + expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); |
| 46 | + }); |
| 47 | + |
| 48 | + afterAll(() => { |
| 49 | + util.teardownStage(stageName); |
| 50 | + }); |
| 51 | +}); |
0 commit comments