1 | const calculateAliasConfig = require('../packages/utils/calculateAliasConfig');
|
2 |
|
3 |
|
4 | jest.mock('../packages/utils/calculateAliasConfig');
|
5 |
|
6 |
|
7 | const process = require('process');
|
8 | const spy = jest.spyOn(process, 'cwd');
|
9 | spy.mockReturnValue('/Users/blue/work/anu/packages/cli/packages/demo');
|
10 |
|
11 | describe('calculate using components path', () => {
|
12 |
|
13 | let sourcePath = '/Users/blue/work/anu/packages/cli/packages/demo/source/pages/syntax/await/index.js';
|
14 |
|
15 |
|
16 |
|
17 | test('import Cat from \'@components/Cat/index\';', ()=>{
|
18 | const calculateComponentsPath = require('../packages/utils/calculateComponentsPath');
|
19 | calculateAliasConfig.mockReturnValue({
|
20 | '@components': '/Users/blue/work/anu/packages/cli/packages/demo/source/components'
|
21 | });
|
22 | expect(
|
23 | calculateComponentsPath({
|
24 | sourcePath: sourcePath,
|
25 | source: '@components/Cat/index'
|
26 | })
|
27 | ).toBe('/components/Cat/index');
|
28 | });
|
29 |
|
30 |
|
31 | test('import Dog from \'@syntaxComponents/Dog/index\';', ()=>{
|
32 | const calculateComponentsPath = require('../packages/utils/calculateComponentsPath');
|
33 | calculateAliasConfig.mockReturnValue({
|
34 | '@syntaxComponents': '/Users/blue/work/anu/packages/cli/packages/demo/source/pages/syntax/components'
|
35 | });
|
36 | expect(
|
37 | calculateComponentsPath({
|
38 | sourcePath: sourcePath,
|
39 | source: '@syntaxComponents/Dog/index'
|
40 | })
|
41 | ).toBe('/pages/syntax/components/Dog/index');
|
42 |
|
43 | });
|
44 |
|
45 | }); |
\ | No newline at end of file |