import { BrowserHashService } from "../../partial-src/service/browserHashService" export function run() { const interval = 500 let initHash = window.location.hash let service = new BrowserHashService() describe("Test browserHas service", () => { it("set test", () => { service.set("a", "1") service.set("b", "2") let geta = service.get("a") if (geta !== "1") { throw new Error("Set hash error") } let getb = service.get("b") if (getb !== "2") { throw new Error("Set hash error") } if (window.location.hash.toString() !== "#a=1&b=2") { throw new Error("Set Error") } service.unset("b") let unsetb = service.get("b") if (unsetb) { throw new Error("unset Error") } if (window.location.hash.toString() !== "#a=1") { throw new Error("") } }) it("syncfromhahs", () => { service.syncFromHash("") if (window.location.hash.toString() !== "") { throw new Error("syncFromHash'' is Error") } service.syncFromHash("#a=1&b=2") if (window.location.hash.toString() !== "#a=1&b=2") { throw new Error("syncFromHash'#...' is Error") } let geta = service.get("a") if (geta !== "1") { throw new Error("Set hash error With syncFromHash") } let getb = service.get("b") if (getb !== "2") { throw new Error("Set hash error With syncFromHash") } service.syncFromHash("a=1&b=2") if (window.location.hash.toString() !== "#a=1&b=2") { throw new Error("syncFromHash'...' is Error") } let geta2 = service.get("a") if (geta2 !== "1") { throw new Error("Set hash error With syncFromHash") } let getb2 = service.get("b") if (getb2 !== "2") { throw new Error("Set hash error With syncFromHash") } window.location.hash = initHash }) }) }