Created
May 17, 2020 17:37
-
-
Save Jabher/89f7f8d82fb40e56d80b04901679565e to your computer and use it in GitHub Desktop.
Revisions
-
Jabher created this gist
May 17, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ import { compileTrie } from './compileTrie' import { Trie } from './Trie' const makeTrie = (name: string, ...paths: string[]) => { const trie = new Trie() for (const key of paths) { trie.mapValue(key.split('/'), () => `${name} ${key}`) } return trie } test('compileTrie', () => { expect(compileTrie({ baseTrie: makeTrie('main', ':/bar', ':/:' ), extraTries: [ makeTrie('extra1','foo/:'), makeTrie('extra2', ':/*') ] }).toJSON()).toEqual({ ":>:": [ "extra2 :/*", "main :/:" ], ":>bar": [ "extra2 :/*", "main :/bar" ], "foo>:": [ "extra2 :/*", "extra1 foo/:", "main :/:" ], "foo>bar": [ "extra2 :/*", "extra1 foo/:", "main :/bar" ] }) })