|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | 2 |
|
3 | | -import { EMPTY_OR_SPACED_WORDS_REGEX, ITEM_NAME_REGEX } from './regex'; |
| 3 | +import { ITEM_NAME_REGEX } from './regex'; |
4 | 4 |
|
5 | 5 | describe('Globals', () => { |
6 | 6 | describe('Item name regex', () => { |
7 | 7 | it('Name regex accepts words with spaces', () => { |
8 | 8 | expect(new RegExp(ITEM_NAME_REGEX).test('Course')).toBeTruthy(); |
9 | 9 | expect(new RegExp(ITEM_NAME_REGEX).test('My Course')).toBeTruthy(); |
10 | 10 | expect(new RegExp(ITEM_NAME_REGEX).test('My Course from yesterday')).toBeTruthy(); |
| 11 | + // double space is allowed (users have created content with it already) |
| 12 | + expect(new RegExp(ITEM_NAME_REGEX).test('My Course')).toBeTruthy(); |
11 | 13 | }); |
12 | 14 | it('Name regex rejects string ending with spaces', () => { |
13 | 15 | expect(new RegExp(ITEM_NAME_REGEX).test('My Course from yesterday ')).toBeFalsy(); |
14 | 16 | expect(new RegExp(ITEM_NAME_REGEX).test(' Course')).toBeFalsy(); |
15 | | - expect(new RegExp(ITEM_NAME_REGEX).test('My Course')).toBeFalsy(); |
16 | | - }); |
17 | | - }); |
18 | | - |
19 | | - describe('Empty or spaced words regex', () => { |
20 | | - it('Regex accepts words separated with one space', () => { |
21 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('Bob')).toBeTruthy(); |
22 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('Bob and Alice')).toBeTruthy(); |
23 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('Bob and Alice')).toBeTruthy(); |
24 | | - }); |
25 | | - it('Regex accepts empty string', () => { |
26 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('')).toBeTruthy(); |
27 | | - }); |
28 | | - it('Regex rejects string ending with spaces', () => { |
29 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('Bob ')).toBeFalsy(); |
30 | | - }); |
31 | | - it('Regex rejects string starting with spaces', () => { |
32 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test(' Bob')).toBeFalsy(); |
33 | | - }); |
34 | | - it('Regex rejects words separated with multiple spaces', () => { |
35 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('Bob Alice')).toBeFalsy(); |
36 | | - expect(new RegExp(EMPTY_OR_SPACED_WORDS_REGEX).test('Bob Alice')).toBeFalsy(); |
37 | 17 | }); |
38 | 18 | }); |
39 | 19 | }); |
0 commit comments