/
plugins.test.ts
31 lines (25 loc) · 1.26 KB
/
plugins.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// eslint-disable-next-line node/no-missing-import
import { replaceAt, generatePluginName } from '../../lib/utils/plugins';
describe('generate plugin name', () => {
it('should return webpack Standard Plugin Name for Name : extract-text-webpack-plugin', () => {
const pluginName = generatePluginName('extract-text-webpack-plugin');
expect(pluginName).toEqual('ExtractTextWebpackPlugin');
});
it('should return webpack Standard Plugin Name for Name : webpack.DefinePlugin', () => {
const pluginName = generatePluginName('webpack.DefinePlugin');
expect(pluginName).toEqual('webpack.DefinePlugin');
});
it('should return webpack Standard Plugin Name for Name : my-plugin-name-1', () => {
const pluginName = generatePluginName('my-plugin-name-1');
expect(pluginName).toEqual('MyPluginName1');
});
it('replaceAt capitalizes first letter', () => {
expect(replaceAt('mystring', 0, 'M')).toEqual('Mystring');
});
it('replaceAt replaces within string', () => {
expect(replaceAt('mystring', 2, '-inserted-')).toEqual('my-inserted-tring');
});
it('replaceAt replaces at end of string', () => {
expect(replaceAt('mystring', 7, '-inserted-')).toEqual('mystrin-inserted-');
});
});