-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathcapabilities.test.ts
More file actions
82 lines (74 loc) · 2.58 KB
/
capabilities.test.ts
File metadata and controls
82 lines (74 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import test from 'node:test';
import assert from 'node:assert/strict';
import { isCommandSupportedOnDevice } from '../capabilities.ts';
import type { DeviceInfo } from '../../utils/device.ts';
const iosSimulator: DeviceInfo = {
platform: 'ios',
id: 'sim-1',
name: 'iPhone',
kind: 'simulator',
};
const iosDevice: DeviceInfo = {
platform: 'ios',
id: 'dev-1',
name: 'iPhone',
kind: 'device',
};
const androidDevice: DeviceInfo = {
platform: 'android',
id: 'and-1',
name: 'Pixel',
kind: 'device',
};
test('iOS simulator-only commands reject iOS devices and Android', () => {
for (const cmd of ['alert', 'pinch']) {
assert.equal(isCommandSupportedOnDevice(cmd, iosSimulator), true, `${cmd} on iOS sim`);
assert.equal(isCommandSupportedOnDevice(cmd, iosDevice), false, `${cmd} on iOS device`);
assert.equal(isCommandSupportedOnDevice(cmd, androidDevice), false, `${cmd} on Android`);
}
});
test('simulator-only iOS commands with Android support reject iOS devices', () => {
for (const cmd of ['record', 'settings', 'swipe']) {
assert.equal(isCommandSupportedOnDevice(cmd, iosSimulator), true, `${cmd} on iOS sim`);
assert.equal(isCommandSupportedOnDevice(cmd, iosDevice), false, `${cmd} on iOS device`);
assert.equal(isCommandSupportedOnDevice(cmd, androidDevice), true, `${cmd} on Android`);
}
});
test('reinstall supports iOS simulator, iOS device, and Android', () => {
assert.equal(isCommandSupportedOnDevice('reinstall', iosSimulator), true, 'reinstall on iOS sim');
assert.equal(isCommandSupportedOnDevice('reinstall', iosDevice), true, 'reinstall on iOS device');
assert.equal(isCommandSupportedOnDevice('reinstall', androidDevice), true, 'reinstall on Android');
});
test('core commands support iOS simulator, iOS device, and Android', () => {
for (const cmd of [
'app-switcher',
'apps',
'back',
'boot',
'click',
'close',
'diff',
'fill',
'find',
'focus',
'get',
'home',
'longpress',
'open',
'press',
'screenshot',
'scroll',
'scrollintoview',
'snapshot',
'type',
'wait',
]) {
assert.equal(isCommandSupportedOnDevice(cmd, iosSimulator), true, `${cmd} on iOS sim`);
assert.equal(isCommandSupportedOnDevice(cmd, iosDevice), true, `${cmd} on iOS device`);
assert.equal(isCommandSupportedOnDevice(cmd, androidDevice), true, `${cmd} on Android`);
}
});
test('unknown commands default to supported', () => {
assert.equal(isCommandSupportedOnDevice('some-future-cmd', iosSimulator), true);
assert.equal(isCommandSupportedOnDevice('some-future-cmd', androidDevice), true);
});