|
1 | | -import path from 'path' |
2 | | - |
3 | 1 | import * as utils from '../src/cli/utils' |
4 | 2 |
|
5 | 3 | describe('cli utils', () => { |
6 | | - const fixture = utils.readFile(path.resolve(__dirname, 'fixtures/cli-utils.js')) |
7 | | - |
8 | 4 | describe('parseCliParams', () => { |
9 | 5 | it('parses CLI parameters', () => { |
10 | 6 | const result = utils.parseCliParams(['a', 'b', '-c', 'd']) |
@@ -61,52 +57,17 @@ describe('cli utils', () => { |
61 | 57 | }) |
62 | 58 | }) |
63 | 59 |
|
64 | | - describe('stripBlockComments', () => { |
65 | | - it('does not strip code', () => { |
66 | | - const result = utils.stripBlockComments(fixture) |
67 | | - |
68 | | - expect(result).toEqual(expect.stringContaining('__code_no_comment__')) |
69 | | - expect(result).toEqual(expect.stringContaining('__code_comment_line__')) |
70 | | - expect(result).toEqual(expect.stringContaining('__code_comment_block__')) |
71 | | - expect(result).toEqual(expect.stringContaining('__code_comment_line_important__')) |
72 | | - expect(result).toEqual(expect.stringContaining('__code_comment_block_important__')) |
73 | | - }) |
74 | | - |
75 | | - it('strips block comments', () => { |
76 | | - const result = utils.stripBlockComments(fixture) |
77 | | - |
78 | | - expect(result).not.toEqual(expect.stringContaining('__comment_block__')) |
79 | | - expect(result).not.toEqual(expect.stringContaining('__comment_block_multiline__')) |
80 | | - expect(result).not.toEqual(expect.stringContaining('__comment_block_code__')) |
81 | | - }) |
82 | | - |
83 | | - it('strips docblock comments', () => { |
84 | | - const result = utils.stripBlockComments(fixture) |
85 | | - |
86 | | - expect(result).not.toEqual(expect.stringContaining('__comment_docblock__')) |
87 | | - }) |
88 | | - |
89 | | - it('does not strip line comments', () => { |
90 | | - const result = utils.stripBlockComments(fixture) |
91 | | - |
92 | | - expect(result).toEqual(expect.stringContaining('__comment_line__')) |
93 | | - expect(result).toEqual(expect.stringContaining('__comment_line_important__')) |
94 | | - expect(result).toEqual(expect.stringContaining('__comment_line_code__')) |
95 | | - expect(result).toEqual(expect.stringContaining('__comment_line_important_code__')) |
96 | | - }) |
97 | | - |
98 | | - it('does not strip important block comments', () => { |
99 | | - const result = utils.stripBlockComments(fixture) |
| 60 | + describe('getSimplePath', () => { |
| 61 | + it('strips leading ./', () => { |
| 62 | + const result = utils.getSimplePath('./test') |
100 | 63 |
|
101 | | - expect(result).toEqual(expect.stringContaining('__comment_block_important__')) |
102 | | - expect(result).toEqual(expect.stringContaining('__comment_block_multiline_important__')) |
103 | | - expect(result).toEqual(expect.stringContaining('__comment_block_important_code__')) |
| 64 | + expect(result).toEqual('test') |
104 | 65 | }) |
105 | 66 |
|
106 | | - it('does not strip important docblock comments', () => { |
107 | | - const result = utils.stripBlockComments(fixture) |
| 67 | + it('returns unchanged path if it does not begin with ./', () => { |
| 68 | + const result = utils.getSimplePath('../test') |
108 | 69 |
|
109 | | - expect(result).toEqual(expect.stringContaining('__comment_docblock_important__')) |
| 70 | + expect(result).toEqual('../test') |
110 | 71 | }) |
111 | 72 | }) |
112 | 73 | }) |
0 commit comments