Part of AppLink login process

This commit is contained in:
simojenki
2021-02-21 09:35:34 +11:00
parent 302efd2878
commit c26a325ee1
20 changed files with 644 additions and 253 deletions

27
tests/smapi.test.ts Normal file
View File

@@ -0,0 +1,27 @@
import request from "supertest";
import { DOMParserImpl } from 'xmldom-ts';
import * as xpath from 'xpath-ts';
import makeServer from "../src/server";
import { SONOS_DISABLED, STRINGS_PATH } from "../src/sonos";
import { aService, InMemoryMusicService } from './builders';
const parseXML = (value: string) => new DOMParserImpl().parseFromString(value);
const select = xpath.useNamespaces({"sonos": "http://sonos.com/sonosapi"})
describe('strings.xml', () => {
const server = makeServer(SONOS_DISABLED, aService(), 'http://localhost:1234', new InMemoryMusicService());
it("should return xml for the strings", async () => {
const res = await request(server).get(STRINGS_PATH).send();
expect(res.status).toEqual(200);
const xml = parseXML(res.text);
const x = select("//sonos:string[@stringId='AppLinkMessage']/text()", xml) as Node[]
expect(x.length).toEqual(1)
expect(x[0]!.nodeValue).toEqual("Linking sonos with bonob")
});
});