@kohost/api-client 1.0.0-alpha.1 → 1.0.0-alpha.3
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/.eslintrc.js +10 -0
- package/bitbucket-pipelines.yml +39 -0
- package/commands/Command.js +38 -0
- package/commands/SetAlarmCommand.js +21 -0
- package/commands/SetCourtesyCommand.js +21 -0
- package/commands/SetDimmerCommand.js +21 -0
- package/commands/SetLockCommand.js +21 -0
- package/commands/SetSceneControllerCommand.js +21 -0
- package/commands/SetSwitchCommand.js +21 -0
- package/commands/SetThermostatCommand.js +21 -0
- package/commands/SetWindowCoveringCommand.js +21 -0
- package/commands/VerifyDocumentCommand.js +24 -0
- package/commands/index.js +21 -0
- package/defs/deviceTypes.js +15 -0
- package/defs/formalDeviceTypes.js +6 -0
- package/defs/http.js +7 -0
- package/defs/index.js +11 -0
- package/errors/AppError.js +8 -0
- package/errors/AuthenticationError.js +9 -0
- package/errors/AuthorizationError.js +9 -0
- package/errors/DeviceCommError.js +9 -0
- package/errors/LoginError.js +9 -0
- package/errors/NotFoundError.js +9 -0
- package/errors/RequestError.js +9 -0
- package/errors/SystemCommError.js +9 -0
- package/errors/TokenExpiredError.js +9 -0
- package/errors/UnprocessableRequestError.js +9 -0
- package/errors/ValidationError.js +9 -0
- package/errors/index.js +15 -0
- package/events/Event.js +33 -0
- package/events/SystemCameraUpdatedEvent.js +17 -0
- package/events/SystemCourtesyUpdatedEvent.js +17 -0
- package/events/SystemDimmerUpdatedEvent.js +17 -0
- package/events/SystemLockUpdatedEvent.js +17 -0
- package/events/SystemReservationUpdatedEvent.js +17 -0
- package/events/SystemSceneControllerUpdatedEvent.js +17 -0
- package/events/SystemSourceUpdatedEvent.js +17 -0
- package/events/SystemSpaceUpdatedEvent.js +17 -0
- package/events/SystemSwitchUpdatedEvent.js +17 -0
- package/events/SystemThermostatUpdatedEvent.js +17 -0
- package/events/SystemUserUpdatedEvent.js +17 -0
- package/events/SystemWindowCoveringUpdatedEvent.js +17 -0
- package/events/index.js +28 -0
- package/http/handleResponseError.js +53 -0
- package/http/handleResponseSuccess.js +15 -0
- package/http/index.js +159 -0
- package/index.js +21 -71
- package/models/acl.js +29 -0
- package/models/admin/customer.js +28 -0
- package/models/admin/property.js +28 -0
- package/models/alarm.js +29 -0
- package/models/application.js +28 -0
- package/models/camera.js +29 -0
- package/models/courtesy.js +33 -0
- package/models/dimmer.js +49 -0
- package/models/discoveredDevice.js +30 -0
- package/models/gateway.js +37 -0
- package/models/index.js +56 -0
- package/models/integration.js +76 -0
- package/models/iotGateway.js +29 -0
- package/models/kohost.js +95 -0
- package/models/lock.js +33 -0
- package/models/mediaSource.js +29 -0
- package/models/motionSensor.js +29 -0
- package/models/reservation.js +36 -0
- package/models/room.js +185 -0
- package/models/scene.js +28 -0
- package/models/sceneController.js +29 -0
- package/models/space.js +99 -0
- package/models/switch.js +33 -0
- package/models/thermostat.js +80 -0
- package/models/ticket.js +91 -0
- package/models/user.js +58 -0
- package/models/windowCovering.js +49 -0
- package/package.json +27 -5
- package/prepare.js +4 -0
- package/schemas/acl.json +111 -0
- package/schemas/admin/customer.json +32 -0
- package/schemas/admin/property.json +54 -0
- package/schemas/alarm.json +5 -5
- package/schemas/application.json +24 -0
- package/schemas/camera.json +41 -0
- package/schemas/courtesy.json +5 -6
- package/schemas/definitions/common.json +21 -0
- package/schemas/{device.json → definitions/device.json} +22 -4
- package/schemas/dimmer.json +8 -5
- package/schemas/discoveredDevice.json +43 -0
- package/schemas/gateway.json +45 -13
- package/schemas/identification.json +35 -0
- package/schemas/integration.json +94 -0
- package/schemas/iotGateway.json +29 -0
- package/schemas/lock.json +8 -5
- package/schemas/mediaSource.json +151 -0
- package/schemas/motionSensor.json +26 -0
- package/schemas/payment.json +38 -0
- package/schemas/reservation.json +66 -0
- package/schemas/room.json +138 -0
- package/schemas/scene.json +118 -0
- package/schemas/sceneController.json +18 -6
- package/schemas/space.json +111 -0
- package/schemas/switch.json +8 -5
- package/schemas/thermostat.json +19 -10
- package/schemas/ticket.json +82 -0
- package/schemas/user.json +124 -0
- package/schemas/windowCovering.json +8 -5
- package/tests/unit/models/space.test.js +31 -0
- package/tests/unit/models/thermostat.test.js +146 -0
- package/useCases/http.json +902 -0
- package/utils/getDeviceTypes.js +7 -0
- package/utils/getFormalDeviceType.js +5 -0
- package/utils/schema.js +28 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://api.kohost.app/schemas/v3/ticket.json",
|
|
4
|
+
"title": "Ticket",
|
|
5
|
+
"description": "A ticket is a request for help from a user.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
10
|
+
},
|
|
11
|
+
"conversation": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"default": [],
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"properties": {
|
|
18
|
+
"id": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"user": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"timestamp": {
|
|
25
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
26
|
+
},
|
|
27
|
+
"body": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"readBy": {
|
|
31
|
+
"type": "array",
|
|
32
|
+
"default": [],
|
|
33
|
+
"items": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": ["user", "id", "timestamp", "body"]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"requester": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"assignedTo": {
|
|
45
|
+
"type": ["string", "null"]
|
|
46
|
+
},
|
|
47
|
+
"status": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": ["open", "pending", "solved", "closed"],
|
|
50
|
+
"default": "open"
|
|
51
|
+
},
|
|
52
|
+
"tags": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"default": [],
|
|
55
|
+
"items": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"createdAt": {
|
|
60
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
61
|
+
},
|
|
62
|
+
"updatedAt": {
|
|
63
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
64
|
+
},
|
|
65
|
+
"solvedAt": {
|
|
66
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
67
|
+
},
|
|
68
|
+
"closedAt": {
|
|
69
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"required": [
|
|
73
|
+
"id",
|
|
74
|
+
"conversation",
|
|
75
|
+
"requester",
|
|
76
|
+
"status",
|
|
77
|
+
"tags",
|
|
78
|
+
"createdAt",
|
|
79
|
+
"updatedAt"
|
|
80
|
+
],
|
|
81
|
+
"additionalProperties": false
|
|
82
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://api.kohost.app/schemas/v3/user.json",
|
|
4
|
+
"title": "User",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["active", "lastName", "roles"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
10
|
+
},
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "user"
|
|
14
|
+
},
|
|
15
|
+
"active": {
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": true
|
|
18
|
+
},
|
|
19
|
+
"firstName": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"lastName": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"phone": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"pattern": "^\\+?[0-9]{1,14}$"
|
|
28
|
+
},
|
|
29
|
+
"email": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"format": "email"
|
|
32
|
+
},
|
|
33
|
+
"hashedPassword": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
},
|
|
36
|
+
"photo": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"jobTitle": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
},
|
|
42
|
+
"dob": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"gender": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
},
|
|
48
|
+
"roles": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"items": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"enum": [
|
|
53
|
+
"Guest",
|
|
54
|
+
"Staff",
|
|
55
|
+
"Faculty",
|
|
56
|
+
"Student",
|
|
57
|
+
"Visitor",
|
|
58
|
+
"Manager",
|
|
59
|
+
"Administrator",
|
|
60
|
+
"SuperAdmin"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"identifications": {
|
|
65
|
+
"type":"array",
|
|
66
|
+
"items": {
|
|
67
|
+
"$ref": "https://api.kohost.app/schemas/v3/identification.json"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"payments": {
|
|
71
|
+
"type":"array",
|
|
72
|
+
"items": {
|
|
73
|
+
"$ref": "https://api.kohost.app/schemas/v3/payment.json"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"preferences": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"properties": {
|
|
80
|
+
"notifications": {
|
|
81
|
+
"type": "array",
|
|
82
|
+
"items": {
|
|
83
|
+
"type": "string"
|
|
84
|
+
},
|
|
85
|
+
"examples": [["roomControl", "marketing"]]
|
|
86
|
+
},
|
|
87
|
+
"location": {
|
|
88
|
+
"title": "The location Schema",
|
|
89
|
+
"type": "boolean",
|
|
90
|
+
"default": false,
|
|
91
|
+
"examples": [true]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"location": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"required": ["accuracy", "latitude", "longitude", "timestamp"],
|
|
98
|
+
"additionalProperties": false,
|
|
99
|
+
"properties": {
|
|
100
|
+
"accuracy": {
|
|
101
|
+
"type": ["number", "null"]
|
|
102
|
+
},
|
|
103
|
+
"latitude": {
|
|
104
|
+
"type": ["number", "null"]
|
|
105
|
+
},
|
|
106
|
+
"longitude": {
|
|
107
|
+
"type": ["number", "null"]
|
|
108
|
+
},
|
|
109
|
+
"timestamp": {
|
|
110
|
+
"type": ["number", "null"]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"createdAt": {
|
|
115
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
116
|
+
},
|
|
117
|
+
"updatedAt": {
|
|
118
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
|
|
119
|
+
},
|
|
120
|
+
"systemData": {
|
|
121
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -6,19 +6,22 @@
|
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"id": {
|
|
9
|
-
"$ref": "https://api.kohost.app/schemas/v3/device.json#/definitions/id"
|
|
9
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
|
|
10
10
|
},
|
|
11
11
|
"type": {
|
|
12
|
-
"$ref": "https://api.kohost.app/schemas/v3/device.json#/definitions/type"
|
|
12
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
|
|
13
|
+
},
|
|
14
|
+
"subType": {
|
|
15
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
|
|
13
16
|
},
|
|
14
17
|
"systemData": {
|
|
15
|
-
"$ref": "https://api.kohost.app/schemas/v3/device.json#/definitions/systemData"
|
|
18
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
16
19
|
},
|
|
17
20
|
"supportedNotifications": {
|
|
18
|
-
"$ref": "https://api.kohost.app/schemas/v3/device.json#/definitions/supportedNotifications"
|
|
21
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
19
22
|
},
|
|
20
23
|
"notification": {
|
|
21
|
-
"$ref": "https://api.kohost.app/schemas/v3/device.json#/definitions/notification"
|
|
24
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
|
|
22
25
|
},
|
|
23
26
|
"position": {
|
|
24
27
|
"type": "number",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const Space = require("../../../models/space");
|
|
2
|
+
|
|
3
|
+
const valid = {
|
|
4
|
+
name: "Test Space",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
test("throws error if invalid name provided ", () => {
|
|
8
|
+
const data = { ...valid };
|
|
9
|
+
data.name = "";
|
|
10
|
+
expect(() => new Space(data)).toThrow();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("sets defaults based on hotelRoom type ", () => {
|
|
14
|
+
const data = { ...valid, type: "hotelRoom" };
|
|
15
|
+
const space = new Space(data);
|
|
16
|
+
expect(space).toHaveProperty("type", "hotelRoom");
|
|
17
|
+
expect(space).toHaveProperty("maximumOccupancy", 2);
|
|
18
|
+
expect(space).toHaveProperty("housekeepingStatus", "dirty");
|
|
19
|
+
expect(space).toHaveProperty("serviceStatus", "inService");
|
|
20
|
+
expect(space).toHaveProperty("features");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("only sets defaults based on hotelRoom type ", () => {
|
|
24
|
+
const data = { ...valid, type: "classRoom" };
|
|
25
|
+
const space = new Space(data);
|
|
26
|
+
expect(space).not.toHaveProperty("type", "hotelRoom");
|
|
27
|
+
expect(space).not.toHaveProperty("maximumOccupancy");
|
|
28
|
+
expect(space).not.toHaveProperty("housekeepingStatus");
|
|
29
|
+
expect(space).not.toHaveProperty("serviceStatus");
|
|
30
|
+
expect(space).not.toHaveProperty("features");
|
|
31
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const Thermostat = require("../../../models/thermostat");
|
|
2
|
+
|
|
3
|
+
const valid = {
|
|
4
|
+
id: "1",
|
|
5
|
+
type: "thermostat",
|
|
6
|
+
name: "Test Thermostat",
|
|
7
|
+
hvacMode: "cool",
|
|
8
|
+
hvacState: "off",
|
|
9
|
+
fanMode: "auto",
|
|
10
|
+
fanState: "off",
|
|
11
|
+
temperatureScale: "fahrenheit",
|
|
12
|
+
supportedHvacModes: ["cool", "heat"],
|
|
13
|
+
supportedFanModes: ["auto", "low"],
|
|
14
|
+
currentTemperature: 72,
|
|
15
|
+
systemData: {},
|
|
16
|
+
setpoints: {
|
|
17
|
+
cool: {
|
|
18
|
+
min: 60,
|
|
19
|
+
max: 85,
|
|
20
|
+
value: 72,
|
|
21
|
+
},
|
|
22
|
+
heat: {
|
|
23
|
+
value: 68,
|
|
24
|
+
min: 60,
|
|
25
|
+
max: 85,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
test("Thermostat properties exist", () => {
|
|
31
|
+
expect(Thermostat.name).toBe("Thermostat");
|
|
32
|
+
expect(Thermostat.actionProperties).toBeDefined();
|
|
33
|
+
expect(Thermostat.actionProperties).toBeInstanceOf(Array);
|
|
34
|
+
expect(Thermostat.actionProperties).toEqual(
|
|
35
|
+
expect.arrayContaining(["hvacMode", "fanMode", "setpoints"])
|
|
36
|
+
);
|
|
37
|
+
expect(Thermostat.validProperties).toBeDefined();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("Thermostat validator exists", () => {
|
|
41
|
+
const thermostat = new Thermostat(valid);
|
|
42
|
+
const validator = thermostat.validator;
|
|
43
|
+
expect(validator).toBeDefined();
|
|
44
|
+
expect(validator).toBeInstanceOf(Function);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("Thermostat schema exists", () => {
|
|
48
|
+
const thermostat = new Thermostat(valid);
|
|
49
|
+
const schema = thermostat.schema;
|
|
50
|
+
expect(schema).toBeDefined();
|
|
51
|
+
expect(schema).toBeInstanceOf(Object);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("throws error if missing all required properties", () => {
|
|
55
|
+
expect(() => new Thermostat()).toThrow();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("throws error if missing any required property", () => {
|
|
59
|
+
const data = {
|
|
60
|
+
id: "1",
|
|
61
|
+
name: "Test Thermostat",
|
|
62
|
+
};
|
|
63
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("throws error if invalid hvacMode provided ", () => {
|
|
67
|
+
const data = { ...valid };
|
|
68
|
+
data.hvacMode = "a";
|
|
69
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("throws error if unsupported hvacMode provided ", () => {
|
|
73
|
+
const data = { ...valid };
|
|
74
|
+
data.supportedHvacModes = ["cool"];
|
|
75
|
+
data.hvacMode = "heat";
|
|
76
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("throws error if invalid hvacState provided ", () => {
|
|
80
|
+
const data = { ...valid };
|
|
81
|
+
data.hvacState = "a";
|
|
82
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("throws error if invalid temperatureScale provided ", () => {
|
|
86
|
+
const data = { ...valid };
|
|
87
|
+
data.temperatureScale = "a";
|
|
88
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("throws error if invalid humidityScale provided ", () => {
|
|
92
|
+
const data = { ...valid };
|
|
93
|
+
data.humidityScale = "a";
|
|
94
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("throws error if invalid fanState provided ", () => {
|
|
98
|
+
const data = { ...valid };
|
|
99
|
+
data.fanState = "a";
|
|
100
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("throws error if currentTemperature is out of range ", () => {
|
|
104
|
+
const data = { ...valid };
|
|
105
|
+
const data2 = { ...valid };
|
|
106
|
+
data.currentTemperature = 131;
|
|
107
|
+
data2.currentTemperature = -1;
|
|
108
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
109
|
+
expect(() => new Thermostat(data2)).toThrow();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("throws error if currentHumidity is out of range ", () => {
|
|
113
|
+
const data = { ...valid };
|
|
114
|
+
const data2 = { ...valid };
|
|
115
|
+
data.currentHumidity = 100;
|
|
116
|
+
data2.currentHumidity = -1;
|
|
117
|
+
expect(() => new Thermostat(data)).toThrow();
|
|
118
|
+
expect(() => new Thermostat(data2)).toThrow();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("returns deltas", () => {
|
|
122
|
+
const thermostat = new Thermostat({ ...valid });
|
|
123
|
+
|
|
124
|
+
const delta1 = Thermostat.getActionDelta(thermostat, {
|
|
125
|
+
hvacMode: "heat",
|
|
126
|
+
setpoints: {
|
|
127
|
+
cool: {
|
|
128
|
+
value: 71,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const delta2 = Thermostat.getActionDelta(thermostat, {
|
|
134
|
+
setpoints: {
|
|
135
|
+
heat: {
|
|
136
|
+
value: 71,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
expect(delta1.hvacMode).toBe(1);
|
|
142
|
+
expect(delta1["setpoints.cool"]).toBeLessThan(0);
|
|
143
|
+
expect(delta1["setpoints.cool"]).toBeGreaterThan(-1);
|
|
144
|
+
expect(delta2["setpoints.heat"]).toBeGreaterThan(0);
|
|
145
|
+
expect(delta2["setpoints.heat"]).toBeLessThan(1);
|
|
146
|
+
});
|