36 lines
951 B
JavaScript
36 lines
951 B
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const { createNotifyPlayerScreens } = require('../src/web/lib/notify-player-screens');
|
|
|
|
test('playlist notifications use the player URL reported by the screen connection', async () => {
|
|
const calls = [];
|
|
const notify = createNotifyPlayerScreens(
|
|
async function () {
|
|
calls.push({ type: 'fallback' });
|
|
return { ok: true };
|
|
},
|
|
async function () {
|
|
return {
|
|
connections: [{ playerPublicBaseUrl: 'http://192.168.0.80:8082' }]
|
|
};
|
|
},
|
|
async function (baseUrl, slug, command) {
|
|
calls.push({ baseUrl, slug, command });
|
|
return { ok: true };
|
|
},
|
|
async function () {
|
|
return 'http://player:8081';
|
|
}
|
|
);
|
|
|
|
const count = await notify(['test'], 'refresh');
|
|
|
|
assert.equal(count, 1);
|
|
assert.deepEqual(calls, [{
|
|
baseUrl: 'http://player:8081',
|
|
slug: 'test',
|
|
command: 'refresh'
|
|
}]);
|
|
});
|