|
1 | 1 | import test from 'ava'; |
2 | 2 |
|
3 | | -import { exactRegex, prefixRegex } from '../'; |
| 3 | +import { exactRegex, prefixRegex, suffixRegex } from '../'; |
4 | 4 |
|
5 | 5 | test('exactRegex supports without flag parameter', (t) => { |
6 | 6 | t.is(exactRegex('foo').toString(), '/^foo$/'); |
7 | 7 | }); |
8 | 8 |
|
| 9 | +test('exactRegex supports with multiple string and without flag parameter', (t) => { |
| 10 | + t.is(exactRegex(['foo', 'bar']).toString(), '/^(?:foo|bar)$/'); |
| 11 | +}); |
| 12 | + |
9 | 13 | test('exactRegex supports with flag parameter', (t) => { |
10 | 14 | t.is(exactRegex('foo', 'i').toString(), '/^foo$/i'); |
11 | 15 | }); |
12 | 16 |
|
| 17 | +test('exactRegex supports with multiple string and flag parameter', (t) => { |
| 18 | + t.is(exactRegex(['foo', 'bar'], 'i').toString(), '/^(?:foo|bar)$/i'); |
| 19 | +}); |
| 20 | + |
13 | 21 | test('exactRegex escapes special characters for Regex', (t) => { |
14 | 22 | t.is(exactRegex('foo(bar)').toString(), '/^foo\\(bar\\)$/'); |
15 | 23 | }); |
16 | 24 |
|
| 25 | +test('exactRegex escapes special characters with multiple string for Regex', (t) => { |
| 26 | + t.is(exactRegex(['foo(bar)', 'baz(qux)']).toString(), '/^(?:foo\\(bar\\)|baz\\(qux\\))$/'); |
| 27 | +}); |
| 28 | + |
17 | 29 | test('prefixRegex supports without flag parameter', (t) => { |
18 | 30 | t.is(prefixRegex('foo').toString(), '/^foo/'); |
19 | 31 | }); |
20 | 32 |
|
| 33 | +test('prefixRegex supports with multiple string and without flag parameter', (t) => { |
| 34 | + t.is(prefixRegex(['foo', 'bar']).toString(), '/^(?:foo|bar)/'); |
| 35 | +}); |
| 36 | + |
21 | 37 | test('prefixRegex supports with flag parameter', (t) => { |
22 | 38 | t.is(prefixRegex('foo', 'i').toString(), '/^foo/i'); |
23 | 39 | }); |
24 | 40 |
|
| 41 | +test('prefixRegex supports with multiple string and flag parameter', (t) => { |
| 42 | + t.is(prefixRegex(['foo', 'bar'], 'i').toString(), '/^(?:foo|bar)/i'); |
| 43 | +}); |
| 44 | + |
25 | 45 | test('prefixRegex escapes special characters for Regex', (t) => { |
26 | 46 | t.is(prefixRegex('foo(bar)').toString(), '/^foo\\(bar\\)/'); |
27 | 47 | }); |
| 48 | + |
| 49 | +test('prefixRegex escapes special characters with multiple string for Regex', (t) => { |
| 50 | + t.is(prefixRegex(['foo(bar)', 'baz(qux)']).toString(), '/^(?:foo\\(bar\\)|baz\\(qux\\))/'); |
| 51 | +}); |
| 52 | + |
| 53 | +test('suffixRegex supports without flag parameter', (t) => { |
| 54 | + t.is(suffixRegex('foo').toString(), '/foo$/'); |
| 55 | +}); |
| 56 | + |
| 57 | +test('suffixRegex supports with multiple string and without flag parameter', (t) => { |
| 58 | + t.is(suffixRegex(['foo', 'bar']).toString(), '/(?:foo|bar)$/'); |
| 59 | +}); |
| 60 | + |
| 61 | +test('suffixRegex supports with flag parameter', (t) => { |
| 62 | + t.is(suffixRegex('foo', 'i').toString(), '/foo$/i'); |
| 63 | +}); |
| 64 | + |
| 65 | +test('suffixRegex supports with multiple string and flag parameter', (t) => { |
| 66 | + t.is(suffixRegex(['foo', 'bar'], 'i').toString(), '/(?:foo|bar)$/i'); |
| 67 | +}); |
| 68 | + |
| 69 | +test('suffixRegex escapes special characters for Regex', (t) => { |
| 70 | + t.is(suffixRegex('foo(bar)').toString(), '/foo\\(bar\\)$/'); |
| 71 | +}); |
| 72 | + |
| 73 | +test('suffixRegex escapes special characters with multiple string for Regex', (t) => { |
| 74 | + t.is(suffixRegex(['foo(bar)', 'baz(qux)']).toString(), '/(?:foo\\(bar\\)|baz\\(qux\\))$/'); |
| 75 | +}); |
0 commit comments