-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ts-config-webpack-plugin): webpack config files regex
- Loading branch information
1 parent
43c6ecd
commit 9d679f3
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/ts-config-webpack-plugin/test/WebpackConfigFiles.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const productionConfig = require('../config/production.config'); | ||
const developmentConfig = require('../config/development.config'); | ||
|
||
function filesRegexTests(filesRegex) { | ||
it('files regex matches .ts file ending', (done) => { | ||
expect(filesRegex.test('demo.ts')).toBe(true); | ||
done(); | ||
}); | ||
|
||
it('files regex matches .tsx file ending', (done) => { | ||
expect(filesRegex.test('demo.tsx')).toBe(true); | ||
done(); | ||
}); | ||
|
||
it('files regex matches .d.ts file ending', (done) => { | ||
expect(filesRegex.test('demo.d.ts')).toBe(true); | ||
done(); | ||
}); | ||
|
||
it('files regex doesn\'t match "asdfts" (escaping the first dot)', (done) => { | ||
expect(filesRegex.test('asdfts')).toBe(false); | ||
done(); | ||
}); | ||
|
||
it('files regex doesn\'t match "asdftsx" (escaping the first dot)', (done) => { | ||
expect(filesRegex.test('asdftsx')).toBe(false); | ||
done(); | ||
}); | ||
|
||
it('files regex doesn\'t match "demo.dxts" (escaping the second dot)', (done) => { | ||
expect(filesRegex.test('demo.dxts')).toBe(false); | ||
done(); | ||
}); | ||
} | ||
|
||
describe('TsConfigWebpackPlugin production config file', () => { | ||
const filesRegex = productionConfig({}).module.rules[0].test; | ||
|
||
filesRegexTests(filesRegex); | ||
}); | ||
|
||
describe('TsConfigWebpackPlugin development config file', () => { | ||
const filesRegex = developmentConfig({}).module.rules[0].test; | ||
|
||
filesRegexTests(filesRegex); | ||
}); |