Mercurial > code > home > repos > streamed-graph
annotate src/suffixLabels.test.ts @ 32:db0e9cbf52e5
WIP converting to the package system that i found can work
author | drewp@bigasterisk.com |
---|---|
date | Tue, 24 Dec 2019 18:37:03 -0800 |
parents | 9ec3cbc8791a |
children | 45ed53428e74 |
rev | line source |
---|---|
20
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
1 // import {describe, test, expect} from 'jest'; |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
2 // import { SuffixLabels } from './suffixLabels'; |
17 | 3 |
20
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
4 // describe('_tailSegments', () => { |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
5 // test("returns right amount", () => { |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
6 // expect(SuffixLabels._tailSegments('http://foo/a/bb', 0)).toEqual(''); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
7 // // t.is(SuffixLabels._tailSegments('http://foo/a/bb', 1), 'bb'); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
8 // // t.is(SuffixLabels._tailSegments('http://foo/a/bb', 2), 'a/bb'); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
9 // // t.is(SuffixLabels._tailSegments('http://foo/a/bb', 3), 'foo/a/bb'); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
10 // // t.is(SuffixLabels._tailSegments('http://foo/a/bb', 4), '/foo/a/bb'); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
11 // // t.is(SuffixLabels._tailSegments('http://foo/a/bb', 5), 'http://foo/a/bb'); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
12 // }); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
13 // // test("_tailSegments ok with trailing slash", (t) => { |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
14 // // t.is(SuffixLabels._tailSegments('http://foo/', 0), ''); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
15 // // t.is(SuffixLabels._tailSegments('http://foo/', 1), ''); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
16 // // t.is(SuffixLabels._tailSegments('http://foo/', 2), 'foo/'); |
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
17
diff
changeset
|
17 // }); |
17 | 18 |
19 | |
20 // describe("suffixLabels", () => { | |
21 // const fakeNode = (uri: string) => { return { nominalValue: uri } }; | |
22 | |
23 // it("returns whole url segments", () => { | |
24 // const suf = new SuffixLabels(); | |
25 // suf._planDisplayForUri('http://a/b/c/dd'); | |
26 // suf._planDisplayForUri('http://a/b/c/ee'); | |
27 | |
28 // t.is(suf.getLabelForNode('http://a/b/c/dd'), 'dd'); | |
29 // t.is(suf.getLabelForNode('http://a/b/c/ee'), 'ee'); | |
30 // }); | |
31 | |
32 // it("doesn't treat a repeated uri as a name clash", () => { | |
33 // const suf = new SuffixLabels(); | |
34 // suf._planDisplayForUri('http://a/b/c'); | |
35 // suf._planDisplayForUri('http://a/b/c'); | |
36 | |
37 // t.is(suf.getLabelForNode('http://a/b/c'), 'c'); | |
38 // }); | |
39 | |
40 // it("moves to two segments when needed", () => { | |
41 // const suf = new SuffixLabels(); | |
42 // suf._planDisplayForUri('http://a/b/c/d'); | |
43 // suf._planDisplayForUri('http://a/b/f/d'); | |
44 | |
45 // t.is(suf.getLabelForNode('http://a/b/c/d'), 'c/d'); | |
46 // t.is(suf.getLabelForNode('http://a/b/f/d'), 'f/d'); | |
47 // }); | |
48 | |
49 // it("is ok with clashes at different segment positions", () => { | |
50 // const suf = new SuffixLabels(); | |
51 // suf._planDisplayForUri('http://z/z/z/a/b/c'); | |
52 // suf._planDisplayForUri('http://a/b/c'); | |
53 | |
54 // t.is(suf.getLabelForNode('http://z/z/z/a/b/c'), 'z/a/b/c'); | |
55 // t.is(suf.getLabelForNode('http://a/b/c'), '/a/b/c'); | |
56 // }); | |
57 | |
58 // it("uses appropriately long suffixes per uri", () => { | |
59 // const suf = new SuffixLabels(); | |
60 // suf._planDisplayForUri('http://a/b/c/d/e'); | |
61 // suf._planDisplayForUri('http://a/b/f/d/e'); | |
62 // suf._planDisplayForUri('http://a/b/c/g'); | |
63 // suf._planDisplayForUri('http://a/z'); | |
64 | |
65 // t.is(suf.getLabelForNode('http://a/b/c/d/e'), 'c/d/e'); | |
66 // t.is(suf.getLabelForNode('http://a/b/f/d/e'), 'f/d/e'); | |
67 // t.is(suf.getLabelForNode('http://a/b/c/g'), 'g'); | |
68 // t.is(suf.getLabelForNode('http://a/z'), 'z'); | |
69 // }); | |
70 | |
71 // }); |