@sebbo2002/node-pyatv 6.0.0-develop.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/check.cjs +10 -0
- package/dist/bin/check.cjs.map +1 -0
- package/dist/bin/check.d.ts +2 -1
- package/dist/bin/check.js +4 -45
- package/dist/bin/check.js.map +1 -1
- package/dist/chunk-TZSWUAOB.js +7 -0
- package/dist/chunk-TZSWUAOB.js.map +1 -0
- package/dist/lib/index.cjs +7 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/{device.d.ts → index.d.cts} +340 -4
- package/dist/lib/index.d.ts +806 -6
- package/dist/lib/index.js +1 -7
- package/dist/lib/index.js.map +1 -1
- package/package.json +18 -9
- package/.editorconfig +0 -12
- package/.eslintignore +0 -4
- package/.eslintrc +0 -60
- package/.mocharc.yml +0 -7
- package/.nycrc +0 -32
- package/CHANGELOG.md +0 -295
- package/check.sh +0 -5
- package/dist/examples/push.d.ts +0 -1
- package/dist/examples/push.js +0 -51
- package/dist/examples/push.js.map +0 -1
- package/dist/lib/device-event.d.ts +0 -44
- package/dist/lib/device-event.js +0 -47
- package/dist/lib/device-event.js.map +0 -1
- package/dist/lib/device-events.d.ts +0 -30
- package/dist/lib/device-events.js +0 -237
- package/dist/lib/device-events.js.map +0 -1
- package/dist/lib/device.js +0 -793
- package/dist/lib/device.js.map +0 -1
- package/dist/lib/fake-spawn.d.ts +0 -43
- package/dist/lib/fake-spawn.js +0 -85
- package/dist/lib/fake-spawn.js.map +0 -1
- package/dist/lib/instance.d.ts +0 -97
- package/dist/lib/instance.js +0 -208
- package/dist/lib/instance.js.map +0 -1
- package/dist/lib/tools.d.ts +0 -12
- package/dist/lib/tools.js +0 -319
- package/dist/lib/tools.js.map +0 -1
- package/dist/lib/types.d.ts +0 -204
- package/dist/lib/types.js +0 -108
- package/dist/lib/types.js.map +0 -1
- package/docs/coverage/base.css +0 -224
- package/docs/coverage/block-navigation.js +0 -87
- package/docs/coverage/cobertura-coverage.xml +0 -2889
- package/docs/coverage/device-event.ts.html +0 -256
- package/docs/coverage/device-events.ts.html +0 -970
- package/docs/coverage/device.ts.html +0 -2518
- package/docs/coverage/fake-spawn.ts.html +0 -448
- package/docs/coverage/favicon.png +0 -0
- package/docs/coverage/index.html +0 -221
- package/docs/coverage/index.ts.html +0 -172
- package/docs/coverage/instance.ts.html +0 -718
- package/docs/coverage/prettify.css +0 -1
- package/docs/coverage/prettify.js +0 -2
- package/docs/coverage/sort-arrow-sprite.png +0 -0
- package/docs/coverage/sorter.js +0 -196
- package/docs/coverage/tools.ts.html +0 -1222
- package/docs/coverage/types.ts.html +0 -775
- package/docs/reference/.nojekyll +0 -1
- package/docs/reference/assets/highlight.css +0 -99
- package/docs/reference/assets/main.js +0 -58
- package/docs/reference/assets/search.js +0 -1
- package/docs/reference/assets/style.css +0 -1280
- package/docs/reference/classes/NodePyATVDevice.html +0 -1266
- package/docs/reference/classes/NodePyATVDeviceEvent.html +0 -123
- package/docs/reference/classes/NodePyATVInstance.html +0 -240
- package/docs/reference/enums/NodePyATVDeviceState.html +0 -97
- package/docs/reference/enums/NodePyATVExecutableType.html +0 -69
- package/docs/reference/enums/NodePyATVKeys.html +0 -216
- package/docs/reference/enums/NodePyATVListenerState.html +0 -83
- package/docs/reference/enums/NodePyATVMediaType.html +0 -83
- package/docs/reference/enums/NodePyATVPowerState.html +0 -69
- package/docs/reference/enums/NodePyATVProtocol.html +0 -83
- package/docs/reference/enums/NodePyATVRepeatState.html +0 -76
- package/docs/reference/enums/NodePyATVShuffleState.html +0 -76
- package/docs/reference/index.html +0 -139
- package/docs/reference/interfaces/NodePyATVDeviceOptions.html +0 -232
- package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +0 -193
- package/docs/reference/interfaces/NodePyATVFindOptions.html +0 -124
- package/docs/reference/interfaces/NodePyATVGetStateOptions.html +0 -66
- package/docs/reference/interfaces/NodePyATVInstanceOptions.html +0 -113
- package/docs/reference/interfaces/NodePyATVService.html +0 -73
- package/docs/reference/interfaces/NodePyATVState.html +0 -164
- package/docs/reference/interfaces/NodePyATVVersionResponse.html +0 -73
- package/docs/reference/modules.html +0 -106
- package/docs/reference/types/NodePyATVEventValueType.html +0 -66
- package/docs/tests/assets/MaterialIcons-Regular.woff +0 -0
- package/docs/tests/assets/MaterialIcons-Regular.woff2 +0 -0
- package/docs/tests/assets/app.css +0 -14
- package/docs/tests/assets/app.js +0 -2
- package/docs/tests/assets/app.js.LICENSE.txt +0 -55
- package/docs/tests/assets/roboto-light-webfont.woff +0 -0
- package/docs/tests/assets/roboto-light-webfont.woff2 +0 -0
- package/docs/tests/assets/roboto-medium-webfont.woff +0 -0
- package/docs/tests/assets/roboto-medium-webfont.woff2 +0 -0
- package/docs/tests/assets/roboto-regular-webfont.woff +0 -0
- package/docs/tests/assets/roboto-regular-webfont.woff2 +0 -0
- package/docs/tests/index.html +0 -2
- package/docs/tests/mochawesome.json +0 -4823
- package/release.config.cjs +0 -51
- package/src/bin/check.ts +0 -41
- package/src/examples/push.ts +0 -46
- package/src/lib/device-event.ts +0 -57
- package/src/lib/device-events.ts +0 -295
- package/src/lib/device.ts +0 -811
- package/src/lib/fake-spawn.ts +0 -121
- package/src/lib/index.ts +0 -29
- package/src/lib/instance.ts +0 -211
- package/src/lib/tools.ts +0 -379
- package/src/lib/types.ts +0 -230
- package/test/device-event.ts +0 -88
- package/test/device-events.ts +0 -502
- package/test/device.ts +0 -826
- package/test/instance.ts +0 -428
- package/test/tools.ts +0 -301
- package/tsconfig.json +0 -19
- package/typedoc.json +0 -15
package/test/instance.ts
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import assert from 'assert';
|
|
4
|
-
import { readFileSync } from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
|
|
8
|
-
import { createFakeSpawn } from '../src/lib/fake-spawn.js';
|
|
9
|
-
import NodePyATVInstance, {
|
|
10
|
-
NodePyATVDeviceEvent,
|
|
11
|
-
NodePyATVDeviceState,
|
|
12
|
-
NodePyATVKeys,
|
|
13
|
-
NodePyATVListenerState,
|
|
14
|
-
NodePyATVMediaType,
|
|
15
|
-
NodePyATVPowerState,
|
|
16
|
-
NodePyATVProtocol,
|
|
17
|
-
NodePyATVRepeatState,
|
|
18
|
-
NodePyATVShuffleState
|
|
19
|
-
} from '../src/lib/index.js';
|
|
20
|
-
|
|
21
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
22
|
-
const __dirname = path.dirname(__filename);
|
|
23
|
-
const version = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf8'))?.version || null;
|
|
24
|
-
|
|
25
|
-
describe('NodePyATVInstance', function () {
|
|
26
|
-
describe('static version()', function () {
|
|
27
|
-
it('should work with pyatv [L]', async function () {
|
|
28
|
-
this.timeout(4000);
|
|
29
|
-
const result = await NodePyATVInstance.version();
|
|
30
|
-
if (result.pyatv === null) {
|
|
31
|
-
throw new Error('No version found for pyatv. Is it installed in test environment?');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
assert.equal(typeof result.pyatv, 'string', 'result.pyatv is a string');
|
|
35
|
-
assert.ok(result.pyatv.length >= 5, 'result.pyatv has content');
|
|
36
|
-
assert.strictEqual(result.module, version);
|
|
37
|
-
});
|
|
38
|
-
it('should return the pyatv version', async function () {
|
|
39
|
-
const result = await NodePyATVInstance.version({
|
|
40
|
-
spawn: createFakeSpawn(cp => {
|
|
41
|
-
cp.code(1);
|
|
42
|
-
cp.end('atvremote 0.7.4');
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
assert.ok(result.pyatv);
|
|
47
|
-
assert.strictEqual(result.pyatv, '0.7.4');
|
|
48
|
-
});
|
|
49
|
-
it('should return the module version', async function () {
|
|
50
|
-
const result = await NodePyATVInstance.version({
|
|
51
|
-
noColors: true,
|
|
52
|
-
spawn: createFakeSpawn(cp =>
|
|
53
|
-
cp.code(1).end()
|
|
54
|
-
)
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
assert.strictEqual(result.module, version);
|
|
58
|
-
});
|
|
59
|
-
it('should handle option.atvremotePath', async function () {
|
|
60
|
-
await NodePyATVInstance.version({
|
|
61
|
-
atvremotePath: '/foo/bar',
|
|
62
|
-
spawn: createFakeSpawn(cp => {
|
|
63
|
-
assert.strictEqual(cp.cmd(), '/foo/bar');
|
|
64
|
-
cp.code(1).end();
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
it('should work with option.debug = true', async function () {
|
|
69
|
-
await NodePyATVInstance.version({
|
|
70
|
-
debug: true,
|
|
71
|
-
spawn: createFakeSpawn(cp =>
|
|
72
|
-
cp.code(1).end()
|
|
73
|
-
)
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
it('should work with option.noColors', async function () {
|
|
77
|
-
await NodePyATVInstance.version({
|
|
78
|
-
debug: () => {
|
|
79
|
-
// no debug log
|
|
80
|
-
},
|
|
81
|
-
noColors: true,
|
|
82
|
-
spawn: createFakeSpawn(cp =>
|
|
83
|
-
cp.code(1).end()
|
|
84
|
-
)
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
it('should return null on pyatv stderr output', async function () {
|
|
88
|
-
const result = await NodePyATVInstance.version({
|
|
89
|
-
spawn: createFakeSpawn(cp =>
|
|
90
|
-
cp.stderr('Hello World!').code(123).end()
|
|
91
|
-
)
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
assert.strictEqual(result.pyatv, null);
|
|
95
|
-
});
|
|
96
|
-
it('should return null on pyatv error', async function () {
|
|
97
|
-
const result = await NodePyATVInstance.version({
|
|
98
|
-
spawn: createFakeSpawn(cp => {
|
|
99
|
-
cp.error(new Error('Hello world!')).end();
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
assert.strictEqual(result.pyatv, null);
|
|
104
|
-
});
|
|
105
|
-
it('should return null on invalid pyatv version', async function () {
|
|
106
|
-
const result = await NodePyATVInstance.version({
|
|
107
|
-
spawn: createFakeSpawn(cp => {
|
|
108
|
-
cp.stdout('atvremote 42').code(1).end();
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
assert.strictEqual(result.pyatv, null);
|
|
113
|
-
});
|
|
114
|
-
/* it('should return null on empty module version', async function () {
|
|
115
|
-
const path = require.resolve(__dirname + '/../package.json');
|
|
116
|
-
require(path);
|
|
117
|
-
|
|
118
|
-
const cache = require.cache[path];
|
|
119
|
-
assert.ok(cache, 'package.json is in require cache');
|
|
120
|
-
|
|
121
|
-
cache.exports = {};
|
|
122
|
-
const result = await NodePyATVInstance.version({
|
|
123
|
-
spawn: createFakeSpawn(cp => {
|
|
124
|
-
cp.stdout('atvremote 0.7.4').code(1).end();
|
|
125
|
-
})
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
assert.strictEqual(result.module, null);
|
|
129
|
-
}); */
|
|
130
|
-
/* it('should return null on invalid module version', async function () {
|
|
131
|
-
const path = require.resolve(__dirname + '/../package.json');
|
|
132
|
-
require(path);
|
|
133
|
-
|
|
134
|
-
const cache = require.cache[path];
|
|
135
|
-
assert.ok(cache, 'package.json is in require cache');
|
|
136
|
-
|
|
137
|
-
cache.exports = {version: 42};
|
|
138
|
-
const result = await NodePyATVInstance.version({
|
|
139
|
-
spawn: createFakeSpawn(cp => {
|
|
140
|
-
cp.stdout('atvremote 0.7.4').code(1).end();
|
|
141
|
-
})
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
assert.strictEqual(result.module, null);
|
|
145
|
-
}); */
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe('static check()', function () {
|
|
149
|
-
it('should resolve in test environment [L]', async function () {
|
|
150
|
-
this.timeout(12000);
|
|
151
|
-
await NodePyATVInstance.check();
|
|
152
|
-
});
|
|
153
|
-
it('should return nice error message if pyatv was not found', async function () {
|
|
154
|
-
await assert.rejects(async () => {
|
|
155
|
-
await NodePyATVInstance.check({
|
|
156
|
-
spawn: createFakeSpawn(cp => {
|
|
157
|
-
cp.error(new Error('spawn atvremote ENOENT')).code(1).end();
|
|
158
|
-
})
|
|
159
|
-
});
|
|
160
|
-
}, /Unable to find pyatv. Is it installed?/);
|
|
161
|
-
});
|
|
162
|
-
it('should return nice error message if myatv is too old', async function () {
|
|
163
|
-
await assert.rejects(async () => {
|
|
164
|
-
await NodePyATVInstance.check({
|
|
165
|
-
spawn: createFakeSpawn(cp => {
|
|
166
|
-
cp.stdout('atvremote 0.5.1').code(1).end();
|
|
167
|
-
})
|
|
168
|
-
});
|
|
169
|
-
}, /Found pyatv, but unforunately it's too old. Please update pyatv./);
|
|
170
|
-
});
|
|
171
|
-
it('should return nice error message if scan failed', async function () {
|
|
172
|
-
let i = 0;
|
|
173
|
-
await assert.rejects(async () => {
|
|
174
|
-
await NodePyATVInstance.check({
|
|
175
|
-
spawn: createFakeSpawn(cp => {
|
|
176
|
-
if (i === 0) {
|
|
177
|
-
cp.stdout('atvremote 0.7.0').code(1).end();
|
|
178
|
-
i++;
|
|
179
|
-
} else {
|
|
180
|
-
cp.error(new Error('spawn atvremote ENOENT')).code(1).end();
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
});
|
|
184
|
-
}, /Unable to scan for devices/);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe('static find()', function () {
|
|
189
|
-
it('should work [L]', async function () {
|
|
190
|
-
this.timeout(8000);
|
|
191
|
-
const result = await NodePyATVInstance.find();
|
|
192
|
-
assert.ok(Array.isArray(result));
|
|
193
|
-
});
|
|
194
|
-
it('should handle option.atvscriptPath', async function () {
|
|
195
|
-
await NodePyATVInstance.find({
|
|
196
|
-
atvscriptPath: '/foo/bar',
|
|
197
|
-
spawn: createFakeSpawn(cp => {
|
|
198
|
-
assert.strictEqual(cp.cmd(), '/foo/bar');
|
|
199
|
-
cp.stdout({
|
|
200
|
-
'result': 'success',
|
|
201
|
-
'datetime': '2020-11-06T20:47:30.840022+01:00',
|
|
202
|
-
'devices': []
|
|
203
|
-
}).end();
|
|
204
|
-
})
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
it('should throw error on stderr output', async function () {
|
|
208
|
-
await assert.rejects(async () => {
|
|
209
|
-
await NodePyATVInstance.find({
|
|
210
|
-
spawn: createFakeSpawn(cp => {
|
|
211
|
-
cp.stderr('Hello World!').code(1).end();
|
|
212
|
-
})
|
|
213
|
-
});
|
|
214
|
-
}, /Unable to execute request/);
|
|
215
|
-
});
|
|
216
|
-
it('should throw error on error', async function () {
|
|
217
|
-
await assert.rejects(async () => {
|
|
218
|
-
await NodePyATVInstance.find({
|
|
219
|
-
spawn: createFakeSpawn(cp => {
|
|
220
|
-
cp.error(new Error('Hello world!')).code(1).end();
|
|
221
|
-
})
|
|
222
|
-
});
|
|
223
|
-
}, /Hello world!/);
|
|
224
|
-
});
|
|
225
|
-
it('should throw error if atvscript result is not valid json', async function () {
|
|
226
|
-
await assert.rejects(async () => {
|
|
227
|
-
await NodePyATVInstance.find({
|
|
228
|
-
spawn: createFakeSpawn(cp => {
|
|
229
|
-
cp.stdout(JSON.stringify({
|
|
230
|
-
'result': 'success',
|
|
231
|
-
'datetime': '2020-11-06T20:47:30.840022+01:00',
|
|
232
|
-
'devices': []
|
|
233
|
-
}).substr(1)).end();
|
|
234
|
-
})
|
|
235
|
-
});
|
|
236
|
-
}, /Unable to parse result/);
|
|
237
|
-
});
|
|
238
|
-
it('should throw error if atvscript result is not successfull', async function () {
|
|
239
|
-
await assert.rejects(async () => {
|
|
240
|
-
await NodePyATVInstance.find({
|
|
241
|
-
spawn: createFakeSpawn(cp => {
|
|
242
|
-
cp.stdout({
|
|
243
|
-
result: 'error'
|
|
244
|
-
}).code(1).end();
|
|
245
|
-
})
|
|
246
|
-
});
|
|
247
|
-
}, /Unable to parse pyatv response: /);
|
|
248
|
-
});
|
|
249
|
-
it('should throw error if atvscript result is without device array', async function () {
|
|
250
|
-
await assert.rejects(async () => {
|
|
251
|
-
await NodePyATVInstance.find({
|
|
252
|
-
spawn: createFakeSpawn(cp => {
|
|
253
|
-
cp.stdout({
|
|
254
|
-
result: 'success'
|
|
255
|
-
}).code(1).end();
|
|
256
|
-
})
|
|
257
|
-
});
|
|
258
|
-
}, /Unable to parse pyatv response: /);
|
|
259
|
-
});
|
|
260
|
-
it('should work if devices are without device_info / services', async function () {
|
|
261
|
-
const devices = await NodePyATVInstance.find({
|
|
262
|
-
spawn: createFakeSpawn(cp => {
|
|
263
|
-
cp.stdout({
|
|
264
|
-
result: 'success',
|
|
265
|
-
datetime: '2020-11-06T20:47:30.840022+01:00',
|
|
266
|
-
devices: [
|
|
267
|
-
{
|
|
268
|
-
name: 'Vardagsrum',
|
|
269
|
-
address: '10.0.10.81',
|
|
270
|
-
identifier: 'xxx'
|
|
271
|
-
}
|
|
272
|
-
]
|
|
273
|
-
}).code(1).end();
|
|
274
|
-
})
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
assert.strictEqual(devices.length, 1);
|
|
278
|
-
assert.strictEqual(devices[0].name, 'Vardagsrum');
|
|
279
|
-
assert.strictEqual(devices[0].host, '10.0.10.81');
|
|
280
|
-
assert.strictEqual(devices[0].id, 'xxx');
|
|
281
|
-
assert.strictEqual(devices[0].model, undefined);
|
|
282
|
-
assert.strictEqual(devices[0].modelName, undefined);
|
|
283
|
-
assert.strictEqual(devices[0].os, undefined);
|
|
284
|
-
assert.strictEqual(devices[0].version, undefined);
|
|
285
|
-
assert.deepStrictEqual(devices[0].services, undefined);
|
|
286
|
-
});
|
|
287
|
-
it('should work if devices are with device_info / services', async function () {
|
|
288
|
-
const devices = await NodePyATVInstance.find({
|
|
289
|
-
spawn: createFakeSpawn(cp => {
|
|
290
|
-
cp.stdout({
|
|
291
|
-
result: 'success',
|
|
292
|
-
datetime: '2020-11-06T20:47:30.840022+01:00',
|
|
293
|
-
devices: [
|
|
294
|
-
{
|
|
295
|
-
name: 'Vardagsrum',
|
|
296
|
-
address: '10.0.10.81',
|
|
297
|
-
identifier: 'xxx',
|
|
298
|
-
device_info: {
|
|
299
|
-
'model': 'Gen4K',
|
|
300
|
-
'model_str': 'Apple TV 4K',
|
|
301
|
-
'operating_system': 'TvOS',
|
|
302
|
-
'version': '15.5.1'
|
|
303
|
-
},
|
|
304
|
-
services: [
|
|
305
|
-
{
|
|
306
|
-
protocol: 'mrp',
|
|
307
|
-
port: 49152
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
protocol: 'airplay',
|
|
311
|
-
port: 7000
|
|
312
|
-
}
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
]
|
|
316
|
-
}).code(1).end();
|
|
317
|
-
})
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
assert.strictEqual(devices.length, 1);
|
|
321
|
-
assert.strictEqual(devices[0].name, 'Vardagsrum');
|
|
322
|
-
assert.strictEqual(devices[0].host, '10.0.10.81');
|
|
323
|
-
assert.strictEqual(devices[0].id, 'xxx');
|
|
324
|
-
assert.strictEqual(devices[0].model, 'Gen4K');
|
|
325
|
-
assert.strictEqual(devices[0].modelName, 'Apple TV 4K');
|
|
326
|
-
assert.strictEqual(devices[0].os, 'TvOS');
|
|
327
|
-
assert.strictEqual(devices[0].version, '15.5.1');
|
|
328
|
-
assert.deepStrictEqual(devices[0].services, [
|
|
329
|
-
{
|
|
330
|
-
protocol: NodePyATVProtocol.mrp,
|
|
331
|
-
port: 49152
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
protocol: NodePyATVProtocol.airplay,
|
|
335
|
-
port: 7000
|
|
336
|
-
}
|
|
337
|
-
]);
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
describe('static device()', function () {
|
|
342
|
-
it('should pass options to constructor', function () {
|
|
343
|
-
const device = NodePyATVInstance.device({ host: '192.168.178.6', name: 'My Testdevice' });
|
|
344
|
-
assert.strictEqual(device.host, '192.168.178.6');
|
|
345
|
-
assert.strictEqual(device.name, 'My Testdevice');
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
describe('version()', function () {
|
|
350
|
-
it('should merge options from constructor', async function () {
|
|
351
|
-
const i = new NodePyATVInstance({ atvremotePath: 'test' });
|
|
352
|
-
await i.version({
|
|
353
|
-
spawn: createFakeSpawn(cp => {
|
|
354
|
-
assert.strictEqual(cp.cmd(), 'test');
|
|
355
|
-
cp.code(1).end();
|
|
356
|
-
})
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
describe('check()', function () {
|
|
362
|
-
it('should merge options from constructor', async function () {
|
|
363
|
-
const i = new NodePyATVInstance({ atvremotePath: 'test' });
|
|
364
|
-
await assert.rejects(async () => {
|
|
365
|
-
await i.check({
|
|
366
|
-
spawn: createFakeSpawn(cp => {
|
|
367
|
-
assert.strictEqual(cp.cmd(), 'test');
|
|
368
|
-
cp.error(new Error('spawn atvremote ENOENT')).code(1).end();
|
|
369
|
-
})
|
|
370
|
-
});
|
|
371
|
-
}, /Unable to find pyatv. Is it installed?/);
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
describe('find()', function () {
|
|
376
|
-
it('should merge options from constructor', async function () {
|
|
377
|
-
const i = new NodePyATVInstance({ atvscriptPath: 'test' });
|
|
378
|
-
await i.find({
|
|
379
|
-
spawn: createFakeSpawn(cp => {
|
|
380
|
-
assert.strictEqual(cp.cmd(), 'test');
|
|
381
|
-
cp.stdout({
|
|
382
|
-
'result': 'success',
|
|
383
|
-
'datetime': '2020-11-06T20:47:30.840022+01:00',
|
|
384
|
-
'devices': []
|
|
385
|
-
}).end();
|
|
386
|
-
})
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
describe('device()', function () {
|
|
392
|
-
it('should merge options from constructor', async function () {
|
|
393
|
-
const i = new NodePyATVInstance({ debug: true });
|
|
394
|
-
const d = i.device({ name: 'My Testdevice', host: '192.168.178.2' });
|
|
395
|
-
assert.deepStrictEqual(d.debug, true);
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
describe('Type Exports', function () {
|
|
400
|
-
it('Type NodePyATVProtocol should be exported', function () {
|
|
401
|
-
assert.ok(NodePyATVProtocol);
|
|
402
|
-
});
|
|
403
|
-
it('Type NodePyATVMediaType should be exported', function () {
|
|
404
|
-
assert.ok(NodePyATVMediaType);
|
|
405
|
-
});
|
|
406
|
-
it('Type NodePyATVDeviceEvent should be exported', function () {
|
|
407
|
-
assert.ok(NodePyATVDeviceEvent);
|
|
408
|
-
});
|
|
409
|
-
it('Type NodePyATVDeviceState should be exported', function () {
|
|
410
|
-
assert.ok(NodePyATVDeviceState);
|
|
411
|
-
});
|
|
412
|
-
it('Type NodePyATVRepeatState should be exported', function () {
|
|
413
|
-
assert.ok(NodePyATVRepeatState);
|
|
414
|
-
});
|
|
415
|
-
it('Type NodePyATVShuffleState should be exported', function () {
|
|
416
|
-
assert.ok(NodePyATVShuffleState);
|
|
417
|
-
});
|
|
418
|
-
it('Type NodePyATVKeys should be exported', function () {
|
|
419
|
-
assert.ok(NodePyATVKeys);
|
|
420
|
-
});
|
|
421
|
-
it('Type NodePyATVInstanceOptions should be exported', function () {
|
|
422
|
-
assert.ok(NodePyATVListenerState);
|
|
423
|
-
});
|
|
424
|
-
it('Type NodePyATVPowerState should be exported', function () {
|
|
425
|
-
assert.ok(NodePyATVPowerState);
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
});
|