annotate src/suffixLabels.test.ts @ 90:6077fdc9ed44

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