| 1 | import * as assert from 'assert'; |
| 2 | |
| 3 | import * as tests from '../../tests'; |
| 4 | import { Pattern, MicromatchOptions } from '../../types'; |
| 5 | import Settings from '../../settings'; |
| 6 | import Matcher, { PatternInfo } from './matcher'; |
| 7 | |
| 8 | class TestMatcher extends Matcher { |
| 9 | public get storage(): PatternInfo[] { |
| 10 | return this._storage; |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | function getMatcher(patterns: Pattern[], options: MicromatchOptions = {}): TestMatcher { |
| 15 | return new TestMatcher(patterns, new Settings(), options); |
| 16 | } |
| 17 | |
| 18 | describe('Providers → Matchers → Matcher', () => { |
| 19 | describe('.storage', () => { |
| 20 | it('should return created storage', () => { |
| 21 | const matcher = getMatcher(['a*', 'a/**/b']); |
| 22 | |
| 23 | const expected: PatternInfo[] = [ |
| 24 | tests.pattern.info() |
| 25 | .section(tests.pattern.segment().dynamic().pattern('a*').build()) |
| 26 | .build(), |
| 27 | tests.pattern.info() |
| 28 | .section(tests.pattern.segment().pattern('a').build()) |
| 29 | .section(tests.pattern.segment().pattern('b').build()) |
| 30 | .build() |
| 31 | ]; |
| 32 | |
| 33 | const actual = matcher.storage; |
| 34 | |
| 35 | assert.deepStrictEqual(actual, expected); |
| 36 | }); |
| 37 | }); |
| 38 | }); |