@ray-js/lamp-schedule-core 1.0.0-beta-5 → 1.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.
|
@@ -43,16 +43,14 @@ describe('transform', () => {
|
|
|
43
43
|
aliasName: 'aliasName',
|
|
44
44
|
isAppPush: false
|
|
45
45
|
});
|
|
46
|
-
expect(result).
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
startTime: '10:00',
|
|
53
|
-
endTime: '10:00'
|
|
54
|
-
}
|
|
46
|
+
expect(result.type).toBe(EScheduleFunctionType.TIMER);
|
|
47
|
+
expect(result.data).toEqual({
|
|
48
|
+
status: true,
|
|
49
|
+
weeks: [1, 0, 0, 0, 0, 0, 0],
|
|
50
|
+
startTime: '10:00',
|
|
51
|
+
endTime: '10:00'
|
|
55
52
|
});
|
|
53
|
+
expect(result.id).toMatch(/^timer_/);
|
|
56
54
|
});
|
|
57
55
|
it('应该处理缺少状态的定时数据', () => {
|
|
58
56
|
const result = timerDataToSchedule({
|
|
@@ -86,8 +84,10 @@ describe('transform', () => {
|
|
|
86
84
|
isAppPush: false
|
|
87
85
|
}]);
|
|
88
86
|
expect(result.length).toBe(2);
|
|
89
|
-
expect(result[0].
|
|
90
|
-
expect(result[1].
|
|
87
|
+
expect(result[0].type).toBe(EScheduleFunctionType.TIMER);
|
|
88
|
+
expect(result[1].type).toBe(EScheduleFunctionType.TIMER);
|
|
89
|
+
expect(result[0].id).toMatch(/^timer_/);
|
|
90
|
+
expect(result[1].id).toMatch(/^timer_/);
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
describe('wakeUpNodeToSchedule', () => {
|
|
@@ -106,16 +106,14 @@ describe('transform', () => {
|
|
|
106
106
|
temperature: 1000,
|
|
107
107
|
index: 1
|
|
108
108
|
});
|
|
109
|
-
expect(result).
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
startTime: '8:20',
|
|
116
|
-
endTime: '8:45'
|
|
117
|
-
}
|
|
109
|
+
expect(result.type).toBe(EScheduleFunctionType.WAKEUP);
|
|
110
|
+
expect(result.data).toEqual({
|
|
111
|
+
status: true,
|
|
112
|
+
weeks: [1, 0, 0, 0, 0, 0, 0],
|
|
113
|
+
startTime: '8:20',
|
|
114
|
+
endTime: '8:45'
|
|
118
115
|
});
|
|
116
|
+
expect(result.id).toMatch(/^wakeup_/);
|
|
119
117
|
});
|
|
120
118
|
});
|
|
121
119
|
describe('wakeUpDataToScheduleList', () => {
|
|
@@ -148,8 +146,10 @@ describe('transform', () => {
|
|
|
148
146
|
index: 2
|
|
149
147
|
}]);
|
|
150
148
|
expect(result.length).toBe(2);
|
|
151
|
-
expect(result[0].
|
|
152
|
-
expect(result[1].
|
|
149
|
+
expect(result[0].type).toBe(EScheduleFunctionType.WAKEUP);
|
|
150
|
+
expect(result[1].type).toBe(EScheduleFunctionType.WAKEUP);
|
|
151
|
+
expect(result[0].id).toMatch(/^wakeup_/);
|
|
152
|
+
expect(result[1].id).toMatch(/^wakeup_/);
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
describe('sleepNodeToSchedule', () => {
|
|
@@ -168,16 +168,14 @@ describe('transform', () => {
|
|
|
168
168
|
temperature: 1000,
|
|
169
169
|
index: 2
|
|
170
170
|
});
|
|
171
|
-
expect(result).
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
startTime: '22:10',
|
|
178
|
-
endTime: '22:30'
|
|
179
|
-
}
|
|
171
|
+
expect(result.type).toBe(EScheduleFunctionType.SLEEP);
|
|
172
|
+
expect(result.data).toEqual({
|
|
173
|
+
status: true,
|
|
174
|
+
weeks: [1, 0, 0, 0, 0, 0, 0],
|
|
175
|
+
startTime: '22:10',
|
|
176
|
+
endTime: '22:30'
|
|
180
177
|
});
|
|
178
|
+
expect(result.id).toMatch(/^sleep_/);
|
|
181
179
|
});
|
|
182
180
|
});
|
|
183
181
|
describe('sleepDataToScheduleList', () => {
|
|
@@ -210,8 +208,10 @@ describe('transform', () => {
|
|
|
210
208
|
index: 2
|
|
211
209
|
}]);
|
|
212
210
|
expect(result.length).toBe(2);
|
|
213
|
-
expect(result[0].
|
|
214
|
-
expect(result[1].
|
|
211
|
+
expect(result[0].type).toBe(EScheduleFunctionType.SLEEP);
|
|
212
|
+
expect(result[1].type).toBe(EScheduleFunctionType.SLEEP);
|
|
213
|
+
expect(result[0].id).toMatch(/^sleep_/);
|
|
214
|
+
expect(result[1].id).toMatch(/^sleep_/);
|
|
215
215
|
});
|
|
216
216
|
});
|
|
217
217
|
describe('countdownToSchedule', () => {
|
|
@@ -278,16 +278,14 @@ describe('transform', () => {
|
|
|
278
278
|
temperature: 1000
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
|
-
expect(result).
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
startTime: '10:00',
|
|
288
|
-
endTime: '12:00'
|
|
289
|
-
}
|
|
281
|
+
expect(result.type).toBe(EScheduleFunctionType.RANDOM);
|
|
282
|
+
expect(result.data).toEqual({
|
|
283
|
+
status: true,
|
|
284
|
+
weeks: [1, 0, 0, 0, 0, 0, 0],
|
|
285
|
+
startTime: '10:00',
|
|
286
|
+
endTime: '12:00'
|
|
290
287
|
});
|
|
288
|
+
expect(result.id).toMatch(/^random_/);
|
|
291
289
|
});
|
|
292
290
|
});
|
|
293
291
|
describe('randomDataToScheduleList', () => {
|
|
@@ -326,8 +324,10 @@ describe('transform', () => {
|
|
|
326
324
|
}
|
|
327
325
|
}]);
|
|
328
326
|
expect(result.length).toBe(2);
|
|
329
|
-
expect(result[0].
|
|
330
|
-
expect(result[1].
|
|
327
|
+
expect(result[0].type).toBe(EScheduleFunctionType.RANDOM);
|
|
328
|
+
expect(result[1].type).toBe(EScheduleFunctionType.RANDOM);
|
|
329
|
+
expect(result[0].id).toMatch(/^random_/);
|
|
330
|
+
expect(result[1].id).toMatch(/^random_/);
|
|
331
331
|
});
|
|
332
332
|
});
|
|
333
333
|
describe('cycleNodeToSchedule', () => {
|
|
@@ -351,16 +351,14 @@ describe('transform', () => {
|
|
|
351
351
|
temperature: 1000
|
|
352
352
|
}
|
|
353
353
|
});
|
|
354
|
-
expect(result).
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
startTime: '10:00',
|
|
361
|
-
endTime: '12:00'
|
|
362
|
-
}
|
|
354
|
+
expect(result.type).toBe(EScheduleFunctionType.CYCLE);
|
|
355
|
+
expect(result.data).toEqual({
|
|
356
|
+
status: true,
|
|
357
|
+
weeks: [1, 0, 0, 0, 0, 0, 0],
|
|
358
|
+
startTime: '10:00',
|
|
359
|
+
endTime: '12:00'
|
|
363
360
|
});
|
|
361
|
+
expect(result.id).toMatch(/^cycle_/);
|
|
364
362
|
});
|
|
365
363
|
});
|
|
366
364
|
describe('cycleDataToScheduleList', () => {
|
|
@@ -403,8 +401,10 @@ describe('transform', () => {
|
|
|
403
401
|
}
|
|
404
402
|
}]);
|
|
405
403
|
expect(result.length).toBe(2);
|
|
406
|
-
expect(result[0].
|
|
407
|
-
expect(result[1].
|
|
404
|
+
expect(result[0].type).toBe(EScheduleFunctionType.CYCLE);
|
|
405
|
+
expect(result[1].type).toBe(EScheduleFunctionType.CYCLE);
|
|
406
|
+
expect(result[0].id).toMatch(/^cycle_/);
|
|
407
|
+
expect(result[1].id).toMatch(/^cycle_/);
|
|
408
408
|
});
|
|
409
409
|
});
|
|
410
410
|
describe('transScheduleListToConflictList', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderHook, act } from '@testing-library/react-hooks';
|
|
2
2
|
import { useCountdownDp, useCountdownDpPull } from '../useCountdownDp';
|
|
3
|
-
import { useBaseLightDp,
|
|
3
|
+
import { useBaseLightDp, useFetchDpData } from '../useBaseLightDp';
|
|
4
4
|
import { scheduleDpCodes } from '../../config/dpCodes';
|
|
5
5
|
// Mock dependencies
|
|
6
6
|
jest.mock('../useBaseLightDp');
|
|
@@ -51,7 +51,7 @@ describe('useCountdownDpPull', () => {
|
|
|
51
51
|
const mockRefresh = jest.fn();
|
|
52
52
|
beforeEach(() => {
|
|
53
53
|
jest.clearAllMocks();
|
|
54
|
-
|
|
54
|
+
useFetchDpData.mockReturnValue({
|
|
55
55
|
refresh: mockRefresh
|
|
56
56
|
});
|
|
57
57
|
});
|
|
@@ -72,11 +72,11 @@ describe('useCountdownDpPull', () => {
|
|
|
72
72
|
});
|
|
73
73
|
it('should use correct dpCode', () => {
|
|
74
74
|
renderHook(() => useCountdownDpPull());
|
|
75
|
-
expect(
|
|
75
|
+
expect(useFetchDpData).toHaveBeenCalledWith([scheduleDpCodes.COUNTDOWN]);
|
|
76
76
|
});
|
|
77
77
|
it('should handle custom dpCode', () => {
|
|
78
78
|
const customDpCode = scheduleDpCodes.COUNTDOWN;
|
|
79
79
|
renderHook(() => useCountdownDpPull(customDpCode));
|
|
80
|
-
expect(
|
|
80
|
+
expect(useFetchDpData).toHaveBeenCalledWith([customDpCode]);
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderHook, act } from '@testing-library/react-hooks';
|
|
2
2
|
import { useTimerReportDp, useTimerReportDpPull } from '../useTimerReportDp';
|
|
3
|
-
import { useBaseLightDp,
|
|
3
|
+
import { useBaseLightDp, useFetchDpData } from '../useBaseLightDp';
|
|
4
4
|
import { useSupport } from '../useCommonSupport';
|
|
5
5
|
import { scheduleDpCodes } from '../../config/dpCodes';
|
|
6
6
|
import { timerReportParser } from '../../dpParser';
|
|
@@ -66,7 +66,7 @@ describe('useTimerReportDpPull', () => {
|
|
|
66
66
|
const mockRefresh = jest.fn();
|
|
67
67
|
beforeEach(() => {
|
|
68
68
|
jest.clearAllMocks();
|
|
69
|
-
|
|
69
|
+
useFetchDpData.mockReturnValue({
|
|
70
70
|
refresh: mockRefresh
|
|
71
71
|
});
|
|
72
72
|
});
|
|
@@ -88,6 +88,6 @@ describe('useTimerReportDpPull', () => {
|
|
|
88
88
|
});
|
|
89
89
|
it('should use correct dpCode', () => {
|
|
90
90
|
renderHook(() => useTimerReportDpPull());
|
|
91
|
-
expect(
|
|
91
|
+
expect(useFetchDpData).toHaveBeenCalledWith([scheduleDpCodes.TIMER_REPORT]);
|
|
92
92
|
});
|
|
93
93
|
});
|