test/server.test.js (764 bytes)
1 "use strict"; 2 const test = require("node:test"); 3 const assert = require("node:assert/strict"); 4 const fs = require("node:fs"); 5 const path = require("node:path"); 6 7 const read = (file) => fs.readFileSync(path.join(__dirname, "..", file), "utf8"); 8 const defaultServer = (file) => read(file).match(/const DEFAULT_SERVER = "([^"]+)";/)[1]; 9 10 test("the add-on can reach its default server and the old address", () => { 11 assert.equal(defaultServer("background.js"), "https://sbmsync.com"); 12 assert.equal(defaultServer("options.js"), "https://sbmsync.com"); 13 // Sign-ins from before the move keep the old address. 14 const hosts = JSON.parse(read("manifest.json")).host_permissions; 15 assert.deepEqual(hosts, ["https://sbmsync.com/*", "https://sbm.subread.space/*"]); 16 });