annotate src/suffixLabels_test.ts @ 11:1988ad250036

suffixLabels test runswith 'inv test'
author drewp@localhost
date Fri, 06 Dec 2019 16:41:19 -0800
parents src/suffixLabels_test.html@a7ba8627a7b6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
1 import { SuffixLabels } from './suffixLabels';
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
2
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
3 describe("_tailSegments", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
4 it("returns right amount", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
5 expect(SuffixLabels._tailSegments('http://foo/a/bb', 0)).toEqual('');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
6 expect(SuffixLabels._tailSegments('http://foo/a/bb', 1)).toEqual('bb');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
7 expect(SuffixLabels._tailSegments('http://foo/a/bb', 2)).toEqual('a/bb');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
8 expect(SuffixLabels._tailSegments('http://foo/a/bb', 3)).toEqual('foo/a/bb');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
9 expect(SuffixLabels._tailSegments('http://foo/a/bb', 4)).toEqual('/foo/a/bb');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
10 expect(SuffixLabels._tailSegments('http://foo/a/bb', 5)).toEqual('http://foo/a/bb');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
11 });
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
12 it("ok with trailing slash", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
13 expect(SuffixLabels._tailSegments('http://foo/', 0)).toEqual('');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
14 expect(SuffixLabels._tailSegments('http://foo/', 1)).toEqual('');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
15 expect(SuffixLabels._tailSegments('http://foo/', 2)).toEqual('foo/');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
16 });
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
17 });
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
18
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
19 describe("suffixLabels", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
20 const fakeNode = (uri: string) => { return { nominalValue: uri } };
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
21
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
22 it("returns whole url segments", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
23 const suf = new SuffixLabels();
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
24 suf._planDisplayForUri('http://a/b/c/dd');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
25 suf._planDisplayForUri('http://a/b/c/ee');
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
26
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
27 expect(suf.getLabelForNode('http://a/b/c/dd')).toEqual('dd');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
28 expect(suf.getLabelForNode('http://a/b/c/ee')).toEqual('ee');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
29 });
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
30
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
31 it("doesn't treat a repeated uri as a name clash", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
32 const suf = new SuffixLabels();
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
33 suf._planDisplayForUri('http://a/b/c');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
34 suf._planDisplayForUri('http://a/b/c');
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
35
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
36 expect(suf.getLabelForNode('http://a/b/c')).toEqual('c');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
37 });
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
38
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
39 it("moves to two segments when needed", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
40 const suf = new SuffixLabels();
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
41 suf._planDisplayForUri('http://a/b/c/d');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
42 suf._planDisplayForUri('http://a/b/f/d');
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
43
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
44 expect(suf.getLabelForNode('http://a/b/c/d')).toEqual('c/d');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
45 expect(suf.getLabelForNode('http://a/b/f/d')).toEqual('f/d');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
46 });
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
47
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
48 it("is ok with clashes at different segment positions", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
49 const suf = new SuffixLabels();
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
50 suf._planDisplayForUri('http://z/z/z/a/b/c');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
51 suf._planDisplayForUri('http://a/b/c');
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
52
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
53 expect(suf.getLabelForNode('http://z/z/z/a/b/c')).toEqual('z/a/b/c');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
54 expect(suf.getLabelForNode('http://a/b/c')).toEqual('/a/b/c');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
55 });
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
56
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
57 it("uses appropriately long suffixes per uri", () => {
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
58 const suf = new SuffixLabels();
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
59 suf._planDisplayForUri('http://a/b/c/d/e');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
60 suf._planDisplayForUri('http://a/b/f/d/e');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
61 suf._planDisplayForUri('http://a/b/c/g');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
62 suf._planDisplayForUri('http://a/z');
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
63
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
64 expect(suf.getLabelForNode('http://a/b/c/d/e')).toEqual('c/d/e');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
65 expect(suf.getLabelForNode('http://a/b/f/d/e')).toEqual('f/d/e');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
66 expect(suf.getLabelForNode('http://a/b/c/g')).toEqual('g');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
67 expect(suf.getLabelForNode('http://a/z')).toEqual('z');
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
68 });
3
a7ba8627a7b6 still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff changeset
69
11
1988ad250036 suffixLabels test runswith 'inv test'
drewp@localhost
parents: 3
diff changeset
70 });