-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathnameValidator.spec.ts
33 lines (29 loc) · 1.67 KB
/
nameValidator.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { NameValidator } from '../src/nameValidator';
describe('NameValidator', () => {
it('should allow alphanumeric notebook names', () => {
expect(NameValidator.validateNotebookName('foo')).toBeFalsy();
expect(NameValidator.validateNotebookName('hello world')).toBeFalsy();
expect(NameValidator.validateNotebookName('hello world 123')).toBeFalsy();
expect(NameValidator.validateNotebookName('123')).toBeFalsy();
});
it('should map to an error message with empty or whitespace names', () => {
expect(NameValidator.validateNotebookName('')).toBeTruthy();
expect(NameValidator.validateNotebookName(' ')).toBeTruthy();
});
it('should not allow names beginning or ending with period', () => {
expect(NameValidator.validateNotebookName('.hello')).toBeTruthy();
expect(NameValidator.validateNotebookName('hello.')).toBeTruthy();
});
it('should not allow certain special characters', () => {
expect(NameValidator.validateNotebookName('test ? character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test * character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test / character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test : character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test < character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test > character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test | character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test " character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test # character')).toBeTruthy();
expect(NameValidator.validateNotebookName('test % character')).toBeTruthy();
});
});