mirror of
https://github.com/SteamFramelyHomebrew/framely.git
synced 2026-10-18 02:01:27 +02:00
20 lines
1.6 KiB
JavaScript
20 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import vm from 'node:vm';
|
|
const calls=[];
|
|
const app=(id,remote,extra={})=>({appid:id,display_name:`Game ${id}`,app_type:1,visible_in_game_list:true,remote_per_client_data:remote,BIsPerClientDataLocal:r=>r.clientid==='local',...extra});
|
|
const context={window:{appStore:{allApps:[app(1,[{clientid:'12',installed:true}]),app(2,[{clientid:'13',installed:true}]),app(3,[{clientid:'12',installed:false}]),app(4,[{clientid:'local',installed:true}]),app(5,[{clientid:'12',installed:true}],{app_type:8192}),app(6,[{clientid:'12',installed:true}],{visible_in_game_list:false})]},RemotePlayStore_SteamUI:{devices:[{clientId:'12',status:'Connected'},{clientId:'13',status:'Disconnected'},{clientId:'local',status:'Connected'}]}},SteamClient:{Apps:{StreamGame:(...args)=>calls.push(args)}}};
|
|
const query=vm.runInNewContext(`(${fs.readFileSync('src/steam/remote.js','utf8')})`,context);
|
|
assert.deepEqual(JSON.parse(JSON.stringify(await query({mode:'list'}))),[{id:1,name:'Game 1',client:'12'}]);
|
|
assert.equal(await query({mode:'launch',id:1,client:'13'}),false);
|
|
assert.equal(await query({mode:'launch',id:999,client:'12'}),false);
|
|
assert.equal(calls.length,0);
|
|
assert.equal(await query({mode:'launch',id:1,client:'12'}),true);
|
|
assert.deepEqual(calls,[[1,'12',-1]]);
|
|
context.window.RemotePlayStore_SteamUI.devices=[];
|
|
assert.equal(await query({mode:'launch',id:1,client:'12'}),false);
|
|
assert.equal((await query({mode:'list'})).length,0);
|
|
context.window.appStore=null;
|
|
assert.equal((await query({mode:'list'})).length,0);
|
|
console.log('Steam remote inventory and validated launch: passed');
|