2020-10-09 09:56:01 +02:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-10-09 19:43:11 +02:00
|
|
|
import {Navigation, Segment} from "./Navigation.js";
|
|
|
|
import {URLRouter} from "./URLRouter.js";
|
2020-10-09 09:56:01 +02:00
|
|
|
|
|
|
|
export function createNavigation() {
|
2020-10-12 17:49:06 +02:00
|
|
|
return new Navigation(allowsChild);
|
2020-10-09 09:56:01 +02:00
|
|
|
}
|
2020-10-09 19:43:11 +02:00
|
|
|
|
|
|
|
export function createRouter({history, navigation}) {
|
2020-10-12 17:49:06 +02:00
|
|
|
return new URLRouter({history, navigation, stringifyPath, parseUrlPath});
|
2020-10-09 19:43:11 +02:00
|
|
|
}
|
|
|
|
|
2020-10-12 17:49:06 +02:00
|
|
|
function allowsChild(parent, child) {
|
|
|
|
const {type} = child;
|
|
|
|
switch (parent?.type) {
|
|
|
|
case undefined:
|
|
|
|
// allowed root segments
|
|
|
|
return type === "login" || type === "session";
|
|
|
|
case "session":
|
|
|
|
return type === "room" || type === "rooms" || type === "settings";
|
|
|
|
case "rooms":
|
|
|
|
// downside of the approach: both of these will control which tile is selected
|
2021-06-04 09:45:55 +02:00
|
|
|
return type === "room" || type === "empty-grid-tile";
|
2020-10-28 17:42:18 +01:00
|
|
|
case "room":
|
2021-06-30 10:52:39 +02:00
|
|
|
return type === "lightbox" || type === "right-panel";
|
|
|
|
case "right-panel":
|
2021-07-19 17:34:32 +02:00
|
|
|
return type === "details"|| type === "members" || type === "member";
|
2020-10-12 17:49:06 +02:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2020-10-09 19:43:11 +02:00
|
|
|
}
|
|
|
|
|
2021-04-21 15:33:08 +02:00
|
|
|
export function removeRoomFromPath(path, roomId) {
|
|
|
|
const rooms = path.get("rooms");
|
|
|
|
let roomIdGridIndex = -1;
|
|
|
|
// first delete from rooms segment
|
|
|
|
if (rooms) {
|
|
|
|
roomIdGridIndex = rooms.value.indexOf(roomId);
|
|
|
|
if (roomIdGridIndex !== -1) {
|
|
|
|
const idsWithoutRoom = rooms.value.slice();
|
|
|
|
idsWithoutRoom[roomIdGridIndex] = "";
|
|
|
|
path = path.replace(new Segment("rooms", idsWithoutRoom));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const room = path.get("room");
|
|
|
|
// then from room (which occurs with or without rooms)
|
|
|
|
if (room && room.value === roomId) {
|
|
|
|
if (roomIdGridIndex !== -1) {
|
|
|
|
path = path.with(new Segment("empty-grid-tile", roomIdGridIndex));
|
|
|
|
} else {
|
|
|
|
path = path.until("session");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2020-10-09 19:43:11 +02:00
|
|
|
function roomsSegmentWithRoom(rooms, roomId, path) {
|
2020-10-13 13:13:15 +02:00
|
|
|
if(!rooms.value.includes(roomId)) {
|
2020-10-09 19:43:11 +02:00
|
|
|
const emptyGridTile = path.get("empty-grid-tile");
|
2020-10-13 13:13:15 +02:00
|
|
|
const oldRoom = path.get("room");
|
|
|
|
let index = 0;
|
2020-10-09 19:43:11 +02:00
|
|
|
if (emptyGridTile) {
|
|
|
|
index = emptyGridTile.value;
|
2020-10-13 13:13:15 +02:00
|
|
|
} else if (oldRoom) {
|
|
|
|
index = rooms.value.indexOf(oldRoom.value);
|
2020-10-09 19:43:11 +02:00
|
|
|
}
|
2020-10-13 13:13:15 +02:00
|
|
|
const roomIds = rooms.value.slice();
|
|
|
|
roomIds[index] = roomId;
|
|
|
|
return new Segment("rooms", roomIds);
|
|
|
|
} else {
|
|
|
|
return rooms;
|
|
|
|
}
|
2020-10-09 19:43:11 +02:00
|
|
|
}
|
|
|
|
|
2021-07-19 17:34:32 +02:00
|
|
|
function pushRightPanelSegment(array, segment, value = true) {
|
2021-06-30 11:07:41 +02:00
|
|
|
array.push(new Segment("right-panel"));
|
2021-07-19 17:34:32 +02:00
|
|
|
array.push(new Segment(segment, value));
|
2021-06-30 11:07:41 +02:00
|
|
|
}
|
|
|
|
|
2021-07-15 11:33:32 +02:00
|
|
|
export function addPanelIfNeeded(navigation, path) {
|
|
|
|
const segments = navigation.path.segments;
|
|
|
|
const i = segments.findIndex(segment => segment.type === "right-panel");
|
2021-07-13 09:35:54 +02:00
|
|
|
let _path = path;
|
2021-07-15 11:33:32 +02:00
|
|
|
if (i !== -1) {
|
|
|
|
_path = path.until("room");
|
|
|
|
_path = _path.with(segments[i]);
|
|
|
|
_path = _path.with(segments[i + 1]);
|
2021-07-13 09:35:54 +02:00
|
|
|
}
|
|
|
|
return _path;
|
|
|
|
}
|
|
|
|
|
2021-05-18 13:52:13 +02:00
|
|
|
export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) {
|
2020-10-12 17:49:06 +02:00
|
|
|
// substr(1) to take of initial /
|
|
|
|
const parts = urlPath.substr(1).split("/");
|
|
|
|
const iterator = parts[Symbol.iterator]();
|
|
|
|
const segments = [];
|
|
|
|
let next;
|
|
|
|
while (!(next = iterator.next()).done) {
|
|
|
|
const type = next.value;
|
|
|
|
if (type === "rooms") {
|
|
|
|
const roomsValue = iterator.next().value;
|
2020-10-13 13:13:35 +02:00
|
|
|
if (roomsValue === undefined) { break; }
|
2020-10-12 17:49:06 +02:00
|
|
|
const roomIds = roomsValue.split(",");
|
|
|
|
segments.push(new Segment(type, roomIds));
|
|
|
|
const selectedIndex = parseInt(iterator.next().value || "0", 10);
|
|
|
|
const roomId = roomIds[selectedIndex];
|
|
|
|
if (roomId) {
|
|
|
|
segments.push(new Segment("room", roomId));
|
|
|
|
} else {
|
|
|
|
segments.push(new Segment("empty-grid-tile", selectedIndex));
|
|
|
|
}
|
|
|
|
} else if (type === "open-room") {
|
|
|
|
const roomId = iterator.next().value;
|
|
|
|
if (!roomId) { break; }
|
|
|
|
const rooms = currentNavPath.get("rooms");
|
|
|
|
if (rooms) {
|
|
|
|
segments.push(roomsSegmentWithRoom(rooms, roomId, currentNavPath));
|
|
|
|
}
|
|
|
|
segments.push(new Segment("room", roomId));
|
2021-07-22 12:54:06 +02:00
|
|
|
// Add right-panel segments from previous path
|
|
|
|
const previousSegments = currentNavPath.segments;
|
|
|
|
const i = previousSegments.findIndex(s => s.type === "right-panel");
|
|
|
|
if (i !== -1) {
|
|
|
|
segments.push(previousSegments[i]);
|
|
|
|
segments.push(previousSegments[i + 1]);
|
2021-05-31 18:44:43 +02:00
|
|
|
}
|
2021-05-18 13:52:13 +02:00
|
|
|
} else if (type === "last-session") {
|
|
|
|
let sessionSegment = currentNavPath.get("session");
|
2021-05-18 14:47:45 +02:00
|
|
|
if (typeof sessionSegment?.value !== "string" && defaultSessionId) {
|
2021-05-18 13:52:13 +02:00
|
|
|
sessionSegment = new Segment("session", defaultSessionId);
|
|
|
|
}
|
|
|
|
if (sessionSegment) {
|
|
|
|
segments.push(sessionSegment);
|
|
|
|
}
|
2021-06-30 11:07:41 +02:00
|
|
|
} else if (type === "details" || type === "members") {
|
|
|
|
pushRightPanelSegment(segments, type);
|
2021-07-19 17:34:32 +02:00
|
|
|
} else if (type === "member") {
|
|
|
|
const userId = iterator.next().value;
|
|
|
|
if (!userId) { break; }
|
|
|
|
pushRightPanelSegment(segments, type, userId);
|
2020-10-09 19:43:11 +02:00
|
|
|
} else {
|
2020-10-12 17:49:06 +02:00
|
|
|
// might be undefined, which will be turned into true by Segment
|
|
|
|
const value = iterator.next().value;
|
|
|
|
segments.push(new Segment(type, value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return segments;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function stringifyPath(path) {
|
|
|
|
let urlPath = "";
|
|
|
|
let prevSegment;
|
|
|
|
for (const segment of path.segments) {
|
|
|
|
switch (segment.type) {
|
|
|
|
case "rooms":
|
|
|
|
urlPath += `/rooms/${segment.value.join(",")}`;
|
|
|
|
break;
|
|
|
|
case "empty-grid-tile":
|
|
|
|
urlPath += `/${segment.value}`;
|
|
|
|
break;
|
|
|
|
case "room":
|
|
|
|
if (prevSegment?.type === "rooms") {
|
|
|
|
const index = prevSegment.value.indexOf(segment.value);
|
|
|
|
urlPath += `/${index}`;
|
|
|
|
} else {
|
|
|
|
urlPath += `/${segment.type}/${segment.value}`;
|
|
|
|
}
|
|
|
|
break;
|
2021-06-30 10:52:39 +02:00
|
|
|
case "right-panel":
|
2021-06-30 11:14:27 +02:00
|
|
|
// Ignore right-panel in url
|
2021-06-17 10:46:10 +02:00
|
|
|
continue;
|
2020-10-12 17:49:06 +02:00
|
|
|
default:
|
|
|
|
urlPath += `/${segment.type}`;
|
|
|
|
if (segment.value && segment.value !== true) {
|
|
|
|
urlPath += `/${segment.value}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prevSegment = segment;
|
|
|
|
}
|
|
|
|
return urlPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function tests() {
|
|
|
|
return {
|
|
|
|
"stringify grid url with focused empty tile": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("empty-grid-tile", 3)
|
|
|
|
]);
|
|
|
|
const urlPath = stringifyPath(path);
|
|
|
|
assert.equal(urlPath, "/session/1/rooms/a,b,c/3");
|
|
|
|
},
|
|
|
|
"stringify grid url with focused room": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const urlPath = stringifyPath(path);
|
|
|
|
assert.equal(urlPath, "/session/1/rooms/a,b,c/1");
|
|
|
|
},
|
2021-06-30 10:52:39 +02:00
|
|
|
"stringify url with right-panel and details segment": assert => {
|
2021-06-17 10:46:10 +02:00
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b"),
|
2021-06-30 10:52:39 +02:00
|
|
|
new Segment("right-panel"),
|
2021-06-17 10:46:10 +02:00
|
|
|
new Segment("details")
|
|
|
|
]);
|
|
|
|
const urlPath = stringifyPath(path);
|
|
|
|
assert.equal(urlPath, "/session/1/rooms/a,b,c/1/details");
|
|
|
|
},
|
2020-10-12 17:49:06 +02:00
|
|
|
"parse grid url path with focused empty tile": assert => {
|
|
|
|
const segments = parseUrlPath("/session/1/rooms/a,b,c/3");
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, ["a", "b", "c"]);
|
|
|
|
assert.equal(segments[2].type, "empty-grid-tile");
|
|
|
|
assert.equal(segments[2].value, 3);
|
|
|
|
},
|
|
|
|
"parse grid url path with focused room": assert => {
|
|
|
|
const segments = parseUrlPath("/session/1/rooms/a,b,c/1");
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, ["a", "b", "c"]);
|
|
|
|
assert.equal(segments[2].type, "room");
|
|
|
|
assert.equal(segments[2].value, "b");
|
|
|
|
},
|
2020-10-13 13:13:35 +02:00
|
|
|
"parse empty grid url": assert => {
|
|
|
|
const segments = parseUrlPath("/session/1/rooms/");
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, [""]);
|
|
|
|
assert.equal(segments[2].type, "empty-grid-tile");
|
|
|
|
assert.equal(segments[2].value, 0);
|
|
|
|
},
|
|
|
|
"parse empty grid url with focus": assert => {
|
|
|
|
const segments = parseUrlPath("/session/1/rooms//1");
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, [""]);
|
|
|
|
assert.equal(segments[2].type, "empty-grid-tile");
|
|
|
|
assert.equal(segments[2].value, 1);
|
|
|
|
},
|
2020-10-12 17:49:06 +02:00
|
|
|
"parse open-room action replacing the current focused room": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const segments = parseUrlPath("/session/1/open-room/d", path);
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, ["a", "d", "c"]);
|
|
|
|
assert.equal(segments[2].type, "room");
|
|
|
|
assert.equal(segments[2].value, "d");
|
|
|
|
},
|
2020-10-13 13:13:47 +02:00
|
|
|
"parse open-room action changing focus to an existing room": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const segments = parseUrlPath("/session/1/open-room/a", path);
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, ["a", "b", "c"]);
|
|
|
|
assert.equal(segments[2].type, "room");
|
|
|
|
assert.equal(segments[2].value, "a");
|
|
|
|
},
|
2021-06-04 12:31:33 +02:00
|
|
|
"parse open-room action changing focus to an existing room with details open": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b"),
|
2021-06-30 10:52:39 +02:00
|
|
|
new Segment("right-panel", true),
|
2021-06-04 12:31:33 +02:00
|
|
|
new Segment("details", true)
|
|
|
|
]);
|
|
|
|
const segments = parseUrlPath("/session/1/open-room/a", path);
|
2021-06-17 10:46:10 +02:00
|
|
|
assert.equal(segments.length, 5);
|
2021-06-04 12:31:33 +02:00
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, ["a", "b", "c"]);
|
|
|
|
assert.equal(segments[2].type, "room");
|
|
|
|
assert.equal(segments[2].value, "a");
|
2021-06-30 10:52:39 +02:00
|
|
|
assert.equal(segments[3].type, "right-panel");
|
2021-06-04 12:31:33 +02:00
|
|
|
assert.equal(segments[3].value, true);
|
2021-06-17 10:46:10 +02:00
|
|
|
assert.equal(segments[4].type, "details");
|
|
|
|
assert.equal(segments[4].value, true);
|
2021-06-04 12:31:33 +02:00
|
|
|
},
|
2020-10-12 17:49:06 +02:00
|
|
|
"parse open-room action setting a room in an empty tile": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("empty-grid-tile", 4)
|
|
|
|
]);
|
|
|
|
const segments = parseUrlPath("/session/1/open-room/d", path);
|
|
|
|
assert.equal(segments.length, 3);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.equal(segments[0].value, "1");
|
|
|
|
assert.equal(segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(segments[1].value, ["a", "b", "c", , "d"]); //eslint-disable-line no-sparse-arrays
|
|
|
|
assert.equal(segments[2].type, "room");
|
|
|
|
assert.equal(segments[2].value, "d");
|
|
|
|
},
|
|
|
|
"parse session url path without id": assert => {
|
|
|
|
const segments = parseUrlPath("/session");
|
|
|
|
assert.equal(segments.length, 1);
|
|
|
|
assert.equal(segments[0].type, "session");
|
|
|
|
assert.strictEqual(segments[0].value, true);
|
2021-04-21 15:33:08 +02:00
|
|
|
},
|
|
|
|
"remove active room from grid path turns it into empty tile": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const newPath = removeRoomFromPath(path, "b");
|
|
|
|
assert.equal(newPath.segments.length, 3);
|
|
|
|
assert.equal(newPath.segments[0].type, "session");
|
|
|
|
assert.equal(newPath.segments[0].value, 1);
|
|
|
|
assert.equal(newPath.segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(newPath.segments[1].value, ["a", "", "c"]);
|
|
|
|
assert.equal(newPath.segments[2].type, "empty-grid-tile");
|
|
|
|
assert.equal(newPath.segments[2].value, 1);
|
|
|
|
},
|
|
|
|
"remove inactive room from grid path": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", "c"]),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const newPath = removeRoomFromPath(path, "a");
|
|
|
|
assert.equal(newPath.segments.length, 3);
|
|
|
|
assert.equal(newPath.segments[0].type, "session");
|
|
|
|
assert.equal(newPath.segments[0].value, 1);
|
|
|
|
assert.equal(newPath.segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(newPath.segments[1].value, ["", "b", "c"]);
|
|
|
|
assert.equal(newPath.segments[2].type, "room");
|
|
|
|
assert.equal(newPath.segments[2].value, "b");
|
|
|
|
},
|
|
|
|
"remove inactive room from grid path with empty tile": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("rooms", ["a", "b", ""]),
|
|
|
|
new Segment("empty-grid-tile", 3)
|
|
|
|
]);
|
|
|
|
const newPath = removeRoomFromPath(path, "b");
|
|
|
|
assert.equal(newPath.segments.length, 3);
|
|
|
|
assert.equal(newPath.segments[0].type, "session");
|
|
|
|
assert.equal(newPath.segments[0].value, 1);
|
|
|
|
assert.equal(newPath.segments[1].type, "rooms");
|
|
|
|
assert.deepEqual(newPath.segments[1].value, ["a", "", ""]);
|
|
|
|
assert.equal(newPath.segments[2].type, "empty-grid-tile");
|
|
|
|
assert.equal(newPath.segments[2].value, 3);
|
|
|
|
},
|
|
|
|
"remove active room": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const newPath = removeRoomFromPath(path, "b");
|
|
|
|
assert.equal(newPath.segments.length, 1);
|
|
|
|
assert.equal(newPath.segments[0].type, "session");
|
|
|
|
assert.equal(newPath.segments[0].value, 1);
|
|
|
|
},
|
|
|
|
"remove inactive room doesn't do anything": assert => {
|
|
|
|
const nav = new Navigation(allowsChild);
|
|
|
|
const path = nav.pathFrom([
|
|
|
|
new Segment("session", 1),
|
|
|
|
new Segment("room", "b")
|
|
|
|
]);
|
|
|
|
const newPath = removeRoomFromPath(path, "a");
|
|
|
|
assert.equal(newPath.segments.length, 2);
|
|
|
|
assert.equal(newPath.segments[0].type, "session");
|
|
|
|
assert.equal(newPath.segments[0].value, 1);
|
|
|
|
assert.equal(newPath.segments[1].type, "room");
|
|
|
|
assert.equal(newPath.segments[1].value, "b");
|
|
|
|
},
|
|
|
|
|
2020-10-09 19:43:11 +02:00
|
|
|
}
|
|
|
|
}
|