@sprucelabs/heartwood-view-controllers 119.0.2 → 119.1.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/build/esm/tests/MockAudioController.d.ts +19 -0
- package/build/esm/tests/MockAudioController.js +56 -0
- package/build/esm/tests/SpyDevice.d.ts +2 -0
- package/build/esm/tests/SpyDevice.js +4 -0
- package/build/esm/types/heartwood.types.d.ts +11 -1
- package/build/tests/MockAudioController.d.ts +19 -0
- package/build/tests/MockAudioController.js +48 -0
- package/build/tests/SpyDevice.d.ts +2 -0
- package/build/tests/SpyDevice.js +7 -0
- package/build/types/heartwood.types.d.ts +11 -1
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AudioController } from '../types/heartwood.types';
|
|
2
|
+
export default class MockAudioController implements AudioController {
|
|
3
|
+
private status;
|
|
4
|
+
private volume;
|
|
5
|
+
private sourceUrl?;
|
|
6
|
+
constructor();
|
|
7
|
+
setVolume(volume: number): void;
|
|
8
|
+
getVolume(): Promise<number>;
|
|
9
|
+
assertVolumeSetTo(expected: number): void;
|
|
10
|
+
setSourceUrl(url: string): void;
|
|
11
|
+
assertSourceUrlSetTo(expected: string): void;
|
|
12
|
+
play(): void;
|
|
13
|
+
assertIsPlaying(): void;
|
|
14
|
+
assertIsNotPlaying(): void;
|
|
15
|
+
pause(): void;
|
|
16
|
+
assertIsPaused(): void;
|
|
17
|
+
assertIsStopped(): void;
|
|
18
|
+
stop(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { assert } from '@sprucelabs/test-utils';
|
|
11
|
+
export default class MockAudioController {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.status = 'pending';
|
|
14
|
+
this.volume = 0;
|
|
15
|
+
}
|
|
16
|
+
setVolume(volume) {
|
|
17
|
+
this.volume = volume;
|
|
18
|
+
}
|
|
19
|
+
getVolume() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return this.volume;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
assertVolumeSetTo(expected) {
|
|
25
|
+
assert.isEqual(this.volume, expected, `Volume was not set to expected. Try audio.setVolume(${expected})`);
|
|
26
|
+
}
|
|
27
|
+
setSourceUrl(url) {
|
|
28
|
+
this.sourceUrl = url;
|
|
29
|
+
}
|
|
30
|
+
assertSourceUrlSetTo(expected) {
|
|
31
|
+
assert.isEqual(this.sourceUrl, expected, `Source URL was not set to expected. Try audio.setSourceUrl('${expected}')`);
|
|
32
|
+
}
|
|
33
|
+
play() {
|
|
34
|
+
this.status = 'playing';
|
|
35
|
+
}
|
|
36
|
+
assertIsPlaying() {
|
|
37
|
+
assert.isEqual(this.status, 'playing', `Audio is not playing when it should be. Try audio.play()`);
|
|
38
|
+
}
|
|
39
|
+
assertIsNotPlaying() {
|
|
40
|
+
assert.isNotEqual(this.status, 'playing', `Audio is playing when it should not be. Try audio.stop() or audio.pause() or don't start it at all.`);
|
|
41
|
+
}
|
|
42
|
+
pause() {
|
|
43
|
+
assert.isEqual(this.status, 'playing', `Audio is not playing so you can't pause.`);
|
|
44
|
+
this.status = 'paused';
|
|
45
|
+
}
|
|
46
|
+
assertIsPaused() {
|
|
47
|
+
assert.isEqual(this.status, 'paused', `Audio is not paused when it should be. Try audio.pause()`);
|
|
48
|
+
}
|
|
49
|
+
assertIsStopped() {
|
|
50
|
+
assert.isEqual(this.status, 'stopped', `Audio was not stopped. Try audio.stope()`);
|
|
51
|
+
}
|
|
52
|
+
stop() {
|
|
53
|
+
assert.isEqual(this.status, 'playing', "Audio is not playing so you can't stop it.");
|
|
54
|
+
this.status = 'stopped';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CachedValue, Device, TheaterSettingValueTypes, TheatreSettingName } from '../types/heartwood.types';
|
|
2
|
+
import MockAudioController from './MockAudioController';
|
|
2
3
|
export default class SpyDevice implements Device {
|
|
3
4
|
lastCommand?: string;
|
|
4
5
|
vibrateCount: number;
|
|
@@ -20,6 +21,7 @@ export default class SpyDevice implements Device {
|
|
|
20
21
|
turnTorchOn(brightness?: number): void;
|
|
21
22
|
getTorchBrightness(): number;
|
|
22
23
|
turnTorchOff(): void;
|
|
24
|
+
AudioController(): MockAudioController;
|
|
23
25
|
}
|
|
24
26
|
interface TrackedCommand {
|
|
25
27
|
command: string;
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { SchemaError } from '@sprucelabs/schema';
|
|
11
|
+
import MockAudioController from './MockAudioController.js';
|
|
11
12
|
export default class SpyDevice {
|
|
12
13
|
constructor() {
|
|
13
14
|
this.vibrateCount = 0;
|
|
@@ -61,4 +62,7 @@ export default class SpyDevice {
|
|
|
61
62
|
turnTorchOff() {
|
|
62
63
|
this.brightness = 0;
|
|
63
64
|
}
|
|
65
|
+
AudioController() {
|
|
66
|
+
return new MockAudioController();
|
|
67
|
+
}
|
|
64
68
|
}
|
|
@@ -537,12 +537,13 @@ export type TimezoneName = ITimezoneName;
|
|
|
537
537
|
*/
|
|
538
538
|
export type Locale = ILocale;
|
|
539
539
|
export type CachedValue = string | number | Record<string, any> | boolean | null;
|
|
540
|
-
export type TheatreSettingName = 'kiosk-mode' | 'load-url' | 'log-destination';
|
|
541
540
|
export interface TheaterSettingValueTypes {
|
|
542
541
|
'kiosk-mode': boolean | null;
|
|
543
542
|
'load-url': string | null;
|
|
544
543
|
'log-destination': string | null;
|
|
544
|
+
'audio-volume': number | null;
|
|
545
545
|
}
|
|
546
|
+
export type TheatreSettingName = keyof TheaterSettingValueTypes;
|
|
546
547
|
export interface Device {
|
|
547
548
|
openUrl(url: string): void;
|
|
548
549
|
vibrate(): void;
|
|
@@ -554,6 +555,15 @@ export interface Device {
|
|
|
554
555
|
turnTorchOff(): void;
|
|
555
556
|
setTheatreSetting<N extends TheatreSettingName>(name: N, value: TheaterSettingValueTypes[N]): void;
|
|
556
557
|
getTheatreSetting<N extends TheatreSettingName>(name: N): Promise<TheaterSettingValueTypes[N] | null>;
|
|
558
|
+
AudioController(): AudioController;
|
|
559
|
+
}
|
|
560
|
+
export interface AudioController {
|
|
561
|
+
play(): void;
|
|
562
|
+
pause(): void;
|
|
563
|
+
stop(): void;
|
|
564
|
+
setVolume(volume: number): void;
|
|
565
|
+
getVolume(): Promise<number | null>;
|
|
566
|
+
setSourceUrl(url: string): void;
|
|
557
567
|
}
|
|
558
568
|
export interface AuthorizerCanOptions<ContractId extends PermissionContractId, Ids extends PermissionId<ContractId> = PermissionId<ContractId>> {
|
|
559
569
|
contractId: ContractId;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AudioController } from '../types/heartwood.types';
|
|
2
|
+
export default class MockAudioController implements AudioController {
|
|
3
|
+
private status;
|
|
4
|
+
private volume;
|
|
5
|
+
private sourceUrl?;
|
|
6
|
+
constructor();
|
|
7
|
+
setVolume(volume: number): void;
|
|
8
|
+
getVolume(): Promise<number>;
|
|
9
|
+
assertVolumeSetTo(expected: number): void;
|
|
10
|
+
setSourceUrl(url: string): void;
|
|
11
|
+
assertSourceUrlSetTo(expected: string): void;
|
|
12
|
+
play(): void;
|
|
13
|
+
assertIsPlaying(): void;
|
|
14
|
+
assertIsNotPlaying(): void;
|
|
15
|
+
pause(): void;
|
|
16
|
+
assertIsPaused(): void;
|
|
17
|
+
assertIsStopped(): void;
|
|
18
|
+
stop(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
4
|
+
class MockAudioController {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.status = 'pending';
|
|
7
|
+
this.volume = 0;
|
|
8
|
+
}
|
|
9
|
+
setVolume(volume) {
|
|
10
|
+
this.volume = volume;
|
|
11
|
+
}
|
|
12
|
+
async getVolume() {
|
|
13
|
+
return this.volume;
|
|
14
|
+
}
|
|
15
|
+
assertVolumeSetTo(expected) {
|
|
16
|
+
test_utils_1.assert.isEqual(this.volume, expected, `Volume was not set to expected. Try audio.setVolume(${expected})`);
|
|
17
|
+
}
|
|
18
|
+
setSourceUrl(url) {
|
|
19
|
+
this.sourceUrl = url;
|
|
20
|
+
}
|
|
21
|
+
assertSourceUrlSetTo(expected) {
|
|
22
|
+
test_utils_1.assert.isEqual(this.sourceUrl, expected, `Source URL was not set to expected. Try audio.setSourceUrl('${expected}')`);
|
|
23
|
+
}
|
|
24
|
+
play() {
|
|
25
|
+
this.status = 'playing';
|
|
26
|
+
}
|
|
27
|
+
assertIsPlaying() {
|
|
28
|
+
test_utils_1.assert.isEqual(this.status, 'playing', `Audio is not playing when it should be. Try audio.play()`);
|
|
29
|
+
}
|
|
30
|
+
assertIsNotPlaying() {
|
|
31
|
+
test_utils_1.assert.isNotEqual(this.status, 'playing', `Audio is playing when it should not be. Try audio.stop() or audio.pause() or don't start it at all.`);
|
|
32
|
+
}
|
|
33
|
+
pause() {
|
|
34
|
+
test_utils_1.assert.isEqual(this.status, 'playing', `Audio is not playing so you can't pause.`);
|
|
35
|
+
this.status = 'paused';
|
|
36
|
+
}
|
|
37
|
+
assertIsPaused() {
|
|
38
|
+
test_utils_1.assert.isEqual(this.status, 'paused', `Audio is not paused when it should be. Try audio.pause()`);
|
|
39
|
+
}
|
|
40
|
+
assertIsStopped() {
|
|
41
|
+
test_utils_1.assert.isEqual(this.status, 'stopped', `Audio was not stopped. Try audio.stope()`);
|
|
42
|
+
}
|
|
43
|
+
stop() {
|
|
44
|
+
test_utils_1.assert.isEqual(this.status, 'playing', "Audio is not playing so you can't stop it.");
|
|
45
|
+
this.status = 'stopped';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = MockAudioController;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CachedValue, Device, TheaterSettingValueTypes, TheatreSettingName } from '../types/heartwood.types';
|
|
2
|
+
import MockAudioController from './MockAudioController';
|
|
2
3
|
export default class SpyDevice implements Device {
|
|
3
4
|
lastCommand?: string;
|
|
4
5
|
vibrateCount: number;
|
|
@@ -20,6 +21,7 @@ export default class SpyDevice implements Device {
|
|
|
20
21
|
turnTorchOn(brightness?: number): void;
|
|
21
22
|
getTorchBrightness(): number;
|
|
22
23
|
turnTorchOff(): void;
|
|
24
|
+
AudioController(): MockAudioController;
|
|
23
25
|
}
|
|
24
26
|
interface TrackedCommand {
|
|
25
27
|
command: string;
|
package/build/tests/SpyDevice.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
|
+
const MockAudioController_1 = __importDefault(require("./MockAudioController"));
|
|
4
8
|
class SpyDevice {
|
|
5
9
|
constructor() {
|
|
6
10
|
this.vibrateCount = 0;
|
|
@@ -52,5 +56,8 @@ class SpyDevice {
|
|
|
52
56
|
turnTorchOff() {
|
|
53
57
|
this.brightness = 0;
|
|
54
58
|
}
|
|
59
|
+
AudioController() {
|
|
60
|
+
return new MockAudioController_1.default();
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
exports.default = SpyDevice;
|
|
@@ -537,12 +537,13 @@ export type TimezoneName = ITimezoneName;
|
|
|
537
537
|
*/
|
|
538
538
|
export type Locale = ILocale;
|
|
539
539
|
export type CachedValue = string | number | Record<string, any> | boolean | null;
|
|
540
|
-
export type TheatreSettingName = 'kiosk-mode' | 'load-url' | 'log-destination';
|
|
541
540
|
export interface TheaterSettingValueTypes {
|
|
542
541
|
'kiosk-mode': boolean | null;
|
|
543
542
|
'load-url': string | null;
|
|
544
543
|
'log-destination': string | null;
|
|
544
|
+
'audio-volume': number | null;
|
|
545
545
|
}
|
|
546
|
+
export type TheatreSettingName = keyof TheaterSettingValueTypes;
|
|
546
547
|
export interface Device {
|
|
547
548
|
openUrl(url: string): void;
|
|
548
549
|
vibrate(): void;
|
|
@@ -554,6 +555,15 @@ export interface Device {
|
|
|
554
555
|
turnTorchOff(): void;
|
|
555
556
|
setTheatreSetting<N extends TheatreSettingName>(name: N, value: TheaterSettingValueTypes[N]): void;
|
|
556
557
|
getTheatreSetting<N extends TheatreSettingName>(name: N): Promise<TheaterSettingValueTypes[N] | null>;
|
|
558
|
+
AudioController(): AudioController;
|
|
559
|
+
}
|
|
560
|
+
export interface AudioController {
|
|
561
|
+
play(): void;
|
|
562
|
+
pause(): void;
|
|
563
|
+
stop(): void;
|
|
564
|
+
setVolume(volume: number): void;
|
|
565
|
+
getVolume(): Promise<number | null>;
|
|
566
|
+
setSourceUrl(url: string): void;
|
|
557
567
|
}
|
|
558
568
|
export interface AuthorizerCanOptions<ContractId extends PermissionContractId, Ids extends PermissionId<ContractId> = PermissionId<ContractId>> {
|
|
559
569
|
contractId: ContractId;
|
package/package.json
CHANGED