-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathpath_spec.ts
36 lines (30 loc) · 1.05 KB
/
path_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
34
35
36
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { map } from 'rxjs/operators';
import { formatValidator } from './format-validator';
import { pathFormat } from './path';
describe('Schematics Path format', () => {
it('accepts correct Paths', done => {
const data = { path: 'a/b/c' };
const dataSchema = {
properties: { path: { type: 'string', format: 'path' } },
};
formatValidator(data, dataSchema, [pathFormat])
.pipe(map(result => expect(result.success).toBe(true)))
.toPromise().then(done, done.fail);
});
it('rejects Paths that are not normalized', done => {
const data = { path: 'a/b/c/../' };
const dataSchema = {
properties: { path: { type: 'string', format: 'path' } },
};
formatValidator(data, dataSchema, [pathFormat])
.pipe(map(result => expect(result.success).toBe(false)))
.toPromise().then(done, done.fail);
});
});