|
1 | 1 | import * as assert from 'assert'; |
2 | 2 |
|
3 | | -import { Pattern } from '../types'; |
| 3 | +import { Pattern, PatternSegment } from '../types'; |
| 4 | +import * as tests from '../tests'; |
4 | 5 | import * as util from './pattern'; |
5 | 6 |
|
6 | 7 | describe('Utils → Pattern', () => { |
@@ -385,6 +386,22 @@ describe('Utils → Pattern', () => { |
385 | 386 | }); |
386 | 387 | }); |
387 | 388 |
|
| 389 | + describe('.getPatternSegments', () => { |
| 390 | + it('should return an array of pattern segments', () => { |
| 391 | + const expected: PatternSegment[] = [ |
| 392 | + tests.pattern.segment().pattern('a').build(), |
| 393 | + tests.pattern.segment().dynamic().pattern('*').build(), |
| 394 | + tests.pattern.segment().pattern('b').build(), |
| 395 | + tests.pattern.segment().dynamic().pattern('**').build(), |
| 396 | + tests.pattern.segment().pattern('c').build() |
| 397 | + ]; |
| 398 | + |
| 399 | + const actual = util.getPatternSegments('a/*/b/**/c', {}); |
| 400 | + |
| 401 | + assert.deepStrictEqual(actual, expected); |
| 402 | + }); |
| 403 | + }); |
| 404 | + |
388 | 405 | describe('.makeRe', () => { |
389 | 406 | it('should return regexp for provided pattern', () => { |
390 | 407 | const actual = util.makeRe('*.js', {}); |
|
0 commit comments