Created
May 17, 2020 17:37
-
-
Save Jabher/89f7f8d82fb40e56d80b04901679565e to your computer and use it in GitHub Desktop.
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 characters
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" | |
] | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment