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