one
Version:
One is a new React Framework that makes Vite serve both native and web.
41 lines (40 loc) • 1.13 kB
JavaScript
import { describe, expect, it } from "vitest";
import { getRouteInfoFromState } from "./getRouteInfo.native.js";
describe("getRouteInfoFromState", function () {
var state = {
routes: [{
name: "dev",
path: "/dev#stack",
params: {
"#": "stack"
}
}]
};
it("drops the hash from pathname and segments", function () {
var info = getRouteInfoFromState(function (_state, asPath) {
return {
path: asPath ? "/(site)/dev#stack" : "/dev#stack",
params: {
"#": "stack"
}
};
}, state);
expect(info.pathname).toBe("/dev");
expect(info.segments).toEqual(["(site)", "dev"]);
expect(info.unstable_globalHref).toBe("/dev#stack");
});
it("drops the query and the hash together", function () {
var info = getRouteInfoFromState(function () {
return {
path: "/dev?x=1#stack",
params: {
x: "1",
"#": "stack"
}
};
}, state);
expect(info.pathname).toBe("/dev");
expect(info.segments).toEqual(["dev"]);
});
});
//# sourceMappingURL=getRouteInfo.test.native.js.map