@ray-js/lamp-schedule-core 1.0.4-beta-12 → 1.0.4-beta-13

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.
@@ -1,29 +1,5 @@
1
1
  import { timerDataToSchedule, timerListToScheduleList, wakeUpNodeToSchedule, wakeUpDataToScheduleList, sleepNodeToSchedule, sleepDataToScheduleList, countdownToSchedule, rhythmToSchedule, randomNodeToSchedule, randomDataToScheduleList, cycleNodeToSchedule, cycleDataToScheduleList, transScheduleListToConflictList } from '../transform';
2
2
  import { EScheduleFunctionType } from '../../types';
3
- // 模拟 dayjs 的 format 方法
4
- jest.mock('dayjs', () => {
5
- return jest.fn(() => ({
6
- format: jest.fn(() => '10:00'),
7
- subtract: jest.fn(() => ({
8
- format: jest.fn(() => '09:00')
9
- })),
10
- add: jest.fn(() => ({
11
- format: jest.fn(() => '11:00')
12
- }))
13
- }));
14
- });
15
-
16
- // 模拟时间工具函数
17
- jest.mock('../../utils/time', () => ({
18
- getBackwardOffsetTimeByHourMins: jest.fn((hour, minute, offset) => `${hour}:${minute + offset}`),
19
- getPreOffsetTimeByHourMins: jest.fn((hour, minute, offset) => `${hour}:${minute - offset}`),
20
- getTimerStrByMinutes: jest.fn(minutes => {
21
- const hour = Math.floor(minutes / 60);
22
- const minute = minutes % 60;
23
- return `${hour < 10 ? '0' + hour : hour}:${minute < 10 ? '0' + minute : minute}`;
24
- })
25
- }));
26
-
27
3
  // 模拟日志函数
28
4
  jest.mock('../../utils/ScheduleLogger', () => ({
29
5
  scheduleLogger: {
@@ -31,6 +7,15 @@ jest.mock('../../utils/ScheduleLogger', () => ({
31
7
  error: jest.fn()
32
8
  }
33
9
  }));
10
+
11
+ // 使用简单的 mock 实现,避免 extend 报错
12
+ jest.mock('dayjs', () => {
13
+ const actualDayjs = jest.requireActual('dayjs');
14
+ return time => {
15
+ const instance = actualDayjs(time || '2023-01-01 10:00:00');
16
+ return instance;
17
+ };
18
+ });
34
19
  describe('transform', () => {
35
20
  describe('timerDataToSchedule', () => {
36
21
  it('应该将定时数据转换为日程对象', () => {
@@ -114,8 +99,8 @@ describe('transform', () => {
114
99
  expect(result.data).toEqual({
115
100
  status: true,
116
101
  weeks: [1, 0, 0, 0, 0, 0, 0],
117
- startTime: '8:20',
118
- endTime: '8:45'
102
+ startTime: '08:20',
103
+ endTime: '08:45'
119
104
  });
120
105
  expect(result.id).toMatch(/^wakeup_/);
121
106
  });
@@ -54,6 +54,7 @@ jest.mock('@ray-js/ray', () => ({
54
54
  describe('useBaseLightDp', () => {
55
55
  beforeEach(() => {
56
56
  jest.clearAllMocks();
57
+ jest.useFakeTimers();
57
58
  devIdOrGroupIdCache.get.mockReturnValue({
58
59
  devId: 'device-1',
59
60
  groupId: ''
@@ -62,6 +63,9 @@ describe('useBaseLightDp', () => {
62
63
  getDpIdByDpCode.mockReturnValue(10);
63
64
  getDpState.mockReturnValue(undefined);
64
65
  });
66
+ afterEach(() => {
67
+ jest.useRealTimers();
68
+ });
65
69
  it('subscribes to emitter and updates state when dp changes', () => {
66
70
  const {
67
71
  result
@@ -238,14 +242,19 @@ describe('useFetch hooks', () => {
238
242
  renderHook(() => useFetchDpDataByMesh(['bright_value']));
239
243
  expect(queryDps).not.toHaveBeenCalled();
240
244
  });
241
- it('useFetchDpData triggers fetch on mount and refresh', () => {
245
+ it('useFetchDpData triggers fetch on refresh', () => {
246
+ // 使用 initFetch: false 避免 useEffect 的自动调用,只测试 refresh 功能
242
247
  const {
243
248
  result
244
- } = renderHook(() => useFetchDpData(['bright_value']));
245
- expect(queryDps).toHaveBeenCalledTimes(1);
249
+ } = renderHook(() => useFetchDpData(['bright_value'], {
250
+ initFetch: false,
251
+ offsetTime: 0
252
+ }));
253
+
254
+ // 手动调用 refresh 触发 fetch
246
255
  act(() => {
247
256
  result.current.refresh();
248
257
  });
249
- expect(queryDps).toHaveBeenCalledTimes(2);
258
+ expect(queryDps).toHaveBeenCalledTimes(1);
250
259
  });
251
260
  });
@@ -2,7 +2,6 @@ import { act, renderHook } from '@testing-library/react-hooks';
2
2
  import { useScheduleInit, useSupport, useCommonSupport, resetIsInit } from '../useCommonSupport';
3
3
  import { emitter } from '../../utils/ScheduleEmit';
4
4
  const initStorageMock = jest.fn().mockResolvedValue(undefined);
5
- const getGroupDpsInfosMock = jest.fn().mockResolvedValue({});
6
5
  const registerDeviceListListenerMock = jest.fn();
7
6
  const registerGroupChangeMock = jest.fn();
8
7
  const onDpDataChangeMock = jest.fn();
@@ -157,7 +156,7 @@ describe('useCommonSupport suite', () => {
157
156
  await Promise.resolve();
158
157
  });
159
158
  expect(result.current.isReady).toBe(true);
160
- expect(getGroupDpsInfosMock).toHaveBeenCalledWith('group-1');
159
+ expect(getGroupInfoMock).toHaveBeenCalled();
161
160
  expect(initDpStateMock).toHaveBeenCalled();
162
161
  });
163
162
  it('handles support init failure', async () => {
@@ -72,11 +72,11 @@ describe('useCountdownDpPull', () => {
72
72
  });
73
73
  it('should use correct dpCode', () => {
74
74
  renderHook(() => useCountdownDpPull());
75
- expect(useFetchDpData).toHaveBeenCalledWith([scheduleDpCodes.COUNTDOWN]);
75
+ expect(useFetchDpData).toHaveBeenCalledWith([scheduleDpCodes.COUNTDOWN], undefined);
76
76
  });
77
77
  it('should handle custom dpCode', () => {
78
78
  const customDpCode = scheduleDpCodes.COUNTDOWN;
79
79
  renderHook(() => useCountdownDpPull(customDpCode));
80
- expect(useFetchDpData).toHaveBeenCalledWith([customDpCode]);
80
+ expect(useFetchDpData).toHaveBeenCalledWith([customDpCode], undefined);
81
81
  });
82
82
  });
@@ -89,6 +89,6 @@ describe('useTimerReportDpPull', () => {
89
89
  });
90
90
  it('should use correct dpCode', () => {
91
91
  renderHook(() => useTimerReportDpPull());
92
- expect(useFetchDpData).toHaveBeenCalledWith([scheduleDpCodes.TIMER_REPORT]);
92
+ expect(useFetchDpData).toHaveBeenCalledWith([scheduleDpCodes.TIMER_REPORT], undefined);
93
93
  });
94
94
  });
@@ -117,8 +117,7 @@ export const getDpDataByMesh = function () {
117
117
  return;
118
118
  }
119
119
  scheduleLogger.debug('getDpDataByMesh 开始查询DP参数 dpCodes:', dpCodes);
120
- const dpIds = dpCodes.map(item => getDpIdByDpCode(item)).filter(i => !!i).map(String); // 简化字符串转换
121
-
120
+ const dpIds = dpCodes.map(item => getDpIdByDpCode(item)).filter(i => !!i).map(String);
122
121
  if (dpIds.length === 0) {
123
122
  scheduleLogger.warn('getDpDataByMesh', dpCodes, '未匹配到 dp');
124
123
  return;
@@ -127,7 +126,7 @@ export const getDpDataByMesh = function () {
127
126
  try {
128
127
  queryDps({
129
128
  deviceId,
130
- dpIds,
129
+ dpIds: dpIds,
131
130
  success: e => {
132
131
  scheduleLogger.debug('getDpDataByMesh 查询DP参数 success:', e);
133
132
  },
@@ -157,8 +156,7 @@ export const fetchDpData = function () {
157
156
  scheduleLogger.error('fetchDpData: 未能获取到deviceId');
158
157
  return;
159
158
  }
160
- const dpIds = dpCodes.map(item => getDpIdByDpCode(item)).filter(i => !!i).map(String); // 简化字符串转换
161
-
159
+ const dpIds = dpCodes.map(item => getDpIdByDpCode(item)).filter(i => !!i).map(String);
162
160
  if (dpIds.length === 0) {
163
161
  scheduleLogger.warn('fetchDpData', dpCodes, '未匹配到 dp');
164
162
  return;
@@ -167,7 +165,7 @@ export const fetchDpData = function () {
167
165
  try {
168
166
  queryDps({
169
167
  deviceId,
170
- dpIds,
168
+ dpIds: dpIds,
171
169
  success: e => {
172
170
  scheduleLogger.debug('fetchDpData 查询DP参数 success:', e);
173
171
  },
@@ -5,7 +5,7 @@ import "core-js/modules/esnext.iterator.every.js";
5
5
  import "core-js/modules/esnext.iterator.for-each.js";
6
6
  import "core-js/modules/esnext.iterator.some.js";
7
7
  import { useEffect, useMemo, useRef, useState } from 'react';
8
- import { getDeviceInfo, getGroupInfo, onDpDataChange, onGroupDpDataChangeEvent, registerDeviceListListener, registerGroupChange, offDpDataChange, offGroupDpDataChangeEvent } from '@ray-js/ray';
8
+ import { getDeviceInfo, getGroupInfo, onDpDataChange, onGroupDpDataChangeEvent, registerDeviceListListener, registerGroupChange } from '@ray-js/ray';
9
9
  import { Support } from '../utils/ScheduleSupport';
10
10
  import { useTimerContext } from '../context/timer/context';
11
11
  import { scheduleLogger, scheduleLogger as ScheduleLogger } from '../utils/ScheduleLogger';
@@ -126,24 +126,6 @@ export const useScheduleInit = props => {
126
126
  }
127
127
  });
128
128
  }
129
- return () => {
130
- offDpDataChange({
131
- success() {
132
- ScheduleLogger.info('useScheduleInit offDpDataChange success');
133
- },
134
- fail(err) {
135
- ScheduleLogger.error('useScheduleInit offDpDataChange fail', err);
136
- }
137
- });
138
- offGroupDpDataChangeEvent({
139
- success() {
140
- ScheduleLogger.info('useScheduleInit offGroupDpDataChangeEvent success');
141
- },
142
- fail(err) {
143
- ScheduleLogger.error('useScheduleInit offGroupDpDataChangeEvent fail', err);
144
- }
145
- });
146
- };
147
129
  }, [_isInit, actions]);
148
130
  useEffect(() => {
149
131
  if (!props.devId && !props.groupId) {
package/lib/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export { useSupport, useScheduleInit, getSupportIns } from './hooks/useCommonSup
15
15
  export { useHourType, useSafeArea, useIsIOS, useHideMenu } from './hooks/useCommon';
16
16
  export { useTimerDp } from './hooks/useTimerDp';
17
17
  export { useSleepDp } from './hooks/useSleepDp';
18
- export { useWakeUpDp } from './hooks/useWakeUpDp';
18
+ export { useWakeUpDp } from './hooks/useWakeupDp';
19
19
  export { useRandomDp } from './hooks/useRandomDp';
20
20
  export { useCycleDp } from './hooks/useCycleDp';
21
21
  export { useWakeUpSupport } from './hooks/useWakeUpSupport';
package/lib/index.js CHANGED
@@ -20,7 +20,7 @@ export { useSupport, useScheduleInit, getSupportIns } from './hooks/useCommonSup
20
20
  export { useHourType, useSafeArea, useIsIOS, useHideMenu } from './hooks/useCommon';
21
21
  export { useTimerDp } from './hooks/useTimerDp';
22
22
  export { useSleepDp } from './hooks/useSleepDp';
23
- export { useWakeUpDp } from './hooks/useWakeUpDp';
23
+ export { useWakeUpDp } from './hooks/useWakeupDp';
24
24
  export { useRandomDp } from './hooks/useRandomDp';
25
25
  export { useCycleDp } from './hooks/useCycleDp';
26
26
  export { useWakeUpSupport } from './hooks/useWakeUpSupport';
@@ -80,166 +80,166 @@ export interface DeviceCapabilities {
80
80
  }
81
81
  export interface DevInfo {
82
82
  /** 产品信息,schema,功能定义都在里面 */
83
- schema: any[];
83
+ schema?: any[];
84
84
  /**
85
85
  * dps
86
86
  * 设备的功能点状态,可以根据对应的 dpid 拿到具体的状态值去做业务逻辑
87
87
  */
88
- dps: Record<string, any>;
88
+ dps?: Record<string, any>;
89
89
  /**
90
90
  * attribute
91
91
  * 产品属性定义,在 backend-ng 平台上可查到对应配置,使用二进制位运算的方式进行管理
92
92
  */
93
- attribute: number;
93
+ attribute?: number;
94
94
  /**
95
95
  * capability
96
96
  * 产品能力值,在 backend-ng 平台上可以查询对应的勾选项,整体业务逻辑会根据该数据进行划分
97
97
  * 区分设备类型也可以根据该属性进行调整,按二进制位运算的方式进行管理
98
98
  */
99
- capability: number;
99
+ capability?: number;
100
100
  /**
101
101
  * dpName
102
102
  * 自定义 dp 的名字,通常在面板里会使用到
103
103
  */
104
- dpName: Record<string, string>;
104
+ dpName?: Record<string, string>;
105
105
  /**
106
106
  * ability
107
107
  * 目前业务很少使用,用于区分特殊类型的设备
108
108
  */
109
- ability: number;
109
+ ability?: number;
110
110
  /**
111
111
  * icon
112
112
  * 设备的 icon url
113
113
  */
114
- icon: string;
114
+ icon?: string;
115
115
  /**
116
116
  * devId
117
117
  * 设备的唯一 id
118
118
  */
119
- devId: string;
119
+ devId?: string;
120
120
  /**
121
121
  * verSw
122
122
  * 设备固件版本号
123
123
  */
124
- verSw: string;
124
+ verSw?: string;
125
125
  /**
126
126
  * isShare
127
127
  * 是否为分享设备,true 则是分享设备
128
128
  */
129
- isShare: boolean;
129
+ isShare?: boolean;
130
130
  /**
131
131
  * bv
132
132
  * 设备的基线版本号
133
133
  */
134
- bv: string;
134
+ bv?: string;
135
135
  /**
136
136
  * uuid
137
137
  * 设备的固件唯一标识
138
138
  */
139
- uuid: string;
139
+ uuid?: string;
140
140
  /**
141
141
  * panelConfig
142
142
  * 产品面板里的配置项,通常在 IoT 平台上可以查看到对应的配置
143
143
  */
144
- panelConfig: Record<string, any>;
144
+ panelConfig?: Record<string, any>;
145
145
  /**
146
146
  * activeTime
147
147
  * 设备激活时间,时间戳
148
148
  */
149
- activeTime: number;
149
+ activeTime?: number;
150
150
  /**
151
151
  * devAttribute
152
152
  * 设备的业务能力拓展,二进制位的方式进行运算
153
153
  */
154
- devAttribute: number;
154
+ devAttribute?: number;
155
155
  /**
156
156
  * pcc
157
157
  * Thing自研蓝牙 mesh 产品的分类标识
158
158
  */
159
- pcc: string;
159
+ pcc?: string;
160
160
  /**
161
161
  * nodeId
162
162
  * 子设备的短地址
163
163
  */
164
- nodeId: string;
164
+ nodeId?: string;
165
165
  /**
166
166
  * parentId
167
167
  * 上级节点 id,子设备/或蓝牙 mesh 设备通常会有该字段,用于内部寻找相关的网关或上级模型来进行业务处理
168
168
  */
169
- parentId: string;
169
+ parentId?: string;
170
170
  /**
171
171
  * category
172
172
  * 产品的分类
173
173
  */
174
- category: string;
174
+ category?: string;
175
175
  /**
176
176
  * standSchemaModel
177
177
  * 标准产品功能集定义模型
178
178
  */
179
- standSchemaModel: any;
179
+ standSchemaModel?: any;
180
180
  /**
181
181
  * productId
182
182
  * 设备对应的产品 id
183
183
  */
184
- productId: string;
184
+ productId?: string;
185
185
  /**
186
186
  * bizAttribute
187
187
  * 设备自主上报的能力位
188
188
  */
189
- bizAttribute: number;
189
+ bizAttribute?: number;
190
190
  /**
191
191
  * meshId
192
192
  * Thing自研的蓝牙 mesh id
193
193
  */
194
- meshId: string;
194
+ meshId?: string;
195
195
  /**
196
196
  * sigmeshId
197
197
  * 当前设备所属行业属性对应的蓝牙 mesh id
198
198
  */
199
- sigmeshId: string;
199
+ sigmeshId?: string;
200
200
  /**
201
201
  * meta
202
202
  * 设备自定义配置元属性,用于存放业务数据
203
203
  */
204
- meta: Record<string, any>;
204
+ meta?: Record<string, any>;
205
205
  /**
206
206
  * isLocalOnline
207
207
  * 本地局域网是否在线
208
208
  */
209
- isLocalOnline: boolean;
209
+ isLocalOnline?: boolean;
210
210
  /** 设备云端在线情况 */
211
- isCloudOnline: boolean;
211
+ isCloudOnline?: boolean;
212
212
  /**
213
213
  * isOnline
214
214
  * 设备总的在线情况,只要一个情况在线,就是在线,复合在线情况
215
215
  */
216
- isOnline: boolean;
216
+ isOnline?: boolean;
217
217
  /**
218
218
  * name
219
219
  * 设备名称
220
220
  */
221
- name: string;
221
+ name?: string;
222
222
  /** groupId */
223
- groupId: string;
223
+ groupId?: string;
224
224
  /**
225
225
  * dpCodes
226
226
  * 标准功能集 code
227
227
  */
228
- dpCodes: Record<string, any>;
228
+ dpCodes?: Record<string, any>;
229
229
  /** 时区信息 */
230
- devTimezoneId: string;
230
+ devTimezoneId?: string;
231
231
  /** 设备的功能点执行的时间 */
232
- dpsTime: Record<string, any>;
232
+ dpsTime?: Record<string, any>;
233
233
  /** 设备纬度 */
234
- latitude: string;
234
+ latitude?: string;
235
235
  /** 设备经度 */
236
- longitude: string;
236
+ longitude?: string;
237
237
  /** 设备ip地址 */
238
- ip: string;
238
+ ip?: string;
239
239
  /** 是否为虚拟设备 */
240
- isVirtualDevice: boolean;
240
+ isVirtualDevice?: boolean;
241
241
  /** zigbeeInstallCode to the cloud to mark the gateway with installation code ability */
242
- isZigbeeInstallCode: boolean;
242
+ isZigbeeInstallCode?: boolean;
243
243
  }
244
244
  export interface GroupDevInfo {
245
245
  /**
@@ -60,6 +60,7 @@ export const navigateToSchedule = (params, data, eventsMap) => {
60
60
  scheduleUrl = `${SCHEDULE_FUNCTIONAL_URL}?groupId=${groupId}`;
61
61
  }
62
62
  // 设置预设数据
63
+ // @ts-ignore
63
64
  ty.presetFunctionalData({
64
65
  url: scheduleUrl,
65
66
  data
@@ -1,5 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.every.js";
3
4
  import "core-js/modules/esnext.iterator.find.js";
4
5
  import "core-js/modules/esnext.iterator.for-each.js";
5
6
  /* eslint-disable no-bitwise */
@@ -233,14 +234,14 @@ export class Support {
233
234
  isSupportCloudTimer = (() => {
234
235
  var _this = this;
235
236
  return function () {
236
- var _this$devInfo;
237
+ var _this$devInfo, _this$devInfo2;
237
238
  let devInfo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
238
239
  // 从 this.getCachedDevInfo() 中将 devInfo 不存在的数据合并到 this.devInfo
239
- const cachedDevInfo = _this.getCachedDevInfo();
240
+ const cachedDevInfo = _this.getCachedDevInfo() || {};
240
241
  const filteredDevInfo = {};
241
242
  const _devInfo = _objectSpread(_objectSpread({}, cachedDevInfo), devInfo);
242
243
  Object.keys(_devInfo).forEach(key => {
243
- if (!(key in cachedDevInfo)) {
244
+ if (cachedDevInfo && !(key in cachedDevInfo)) {
244
245
  filteredDevInfo[key] = devInfo[key];
245
246
  }
246
247
  });
@@ -248,19 +249,27 @@ export class Support {
248
249
  if (!_this.devInfo) {
249
250
  return false;
250
251
  }
251
- return ((_this$devInfo = _this.devInfo) === null || _this$devInfo === void 0 || (_this$devInfo = _this$devInfo.panelConfig) === null || _this$devInfo === void 0 || (_this$devInfo = _this$devInfo.bic) === null || _this$devInfo === void 0 ? void 0 : _this$devInfo.find(i => i.code === 'timer' && i.selected)) !== undefined;
252
+
253
+ // 检查 deviceList,如果存在则检查所有设备是否支持 timer
254
+ const deviceList = (_this$devInfo = _this.devInfo) === null || _this$devInfo === void 0 ? void 0 : _this$devInfo.deviceList;
255
+ if (deviceList && Array.isArray(deviceList) && deviceList.length > 0) {
256
+ return deviceList.every(device => {
257
+ var _device$panelConfig;
258
+ return (device === null || device === void 0 || (_device$panelConfig = device.panelConfig) === null || _device$panelConfig === void 0 || (_device$panelConfig = _device$panelConfig.bic) === null || _device$panelConfig === void 0 ? void 0 : _device$panelConfig.find(i => i.code === 'timer' && i.selected)) !== undefined;
259
+ });
260
+ }
261
+ return ((_this$devInfo2 = _this.devInfo) === null || _this$devInfo2 === void 0 || (_this$devInfo2 = _this$devInfo2.panelConfig) === null || _this$devInfo2 === void 0 || (_this$devInfo2 = _this$devInfo2.bic) === null || _this$devInfo2 === void 0 ? void 0 : _this$devInfo2.find(i => i.code === 'timer' && i.selected)) !== undefined;
252
262
  };
253
263
  })();
254
264
  supportDp = (dpCode, devInfo) => {
265
+ var _this$devInfo3;
255
266
  this.devInfo = devInfo !== null && devInfo !== void 0 ? devInfo : this.getCachedDevInfo();
256
267
  if (!this.devInfo) {
257
268
  !this.isIniting && ScheduleLogger.warn('supportDp: ', 'devInfo is undefined');
258
269
  !this.isIniting && ScheduleLogger.warn('请提前调用 useScheduleInit 的 init 方法');
259
270
  return false;
260
271
  }
261
- const {
262
- schema
263
- } = this.devInfo;
272
+ const schema = (_this$devInfo3 = this.devInfo) === null || _this$devInfo3 === void 0 ? void 0 : _this$devInfo3.schema;
264
273
  if (!schema) {
265
274
  !this.isIniting && ScheduleLogger.warn('supportDp: ', 'schema is undefined');
266
275
  return false;
@@ -365,7 +374,7 @@ export class Support {
365
374
  * @returns {boolean} - 是否是 Matter 设备
366
375
  */
367
376
  isMatterDevice(devInfo, isMatter) {
368
- var _this$devInfo2;
377
+ var _this$devInfo4;
369
378
  if (isMatter !== undefined) {
370
379
  return isMatter;
371
380
  }
@@ -373,30 +382,30 @@ export class Support {
373
382
  return !!devInfo.isMatter;
374
383
  }
375
384
  this.devInfo = this.getCachedDevInfo();
376
- return !!((_this$devInfo2 = this.devInfo) !== null && _this$devInfo2 !== void 0 && _this$devInfo2.isMatter);
385
+ return !!((_this$devInfo4 = this.devInfo) !== null && _this$devInfo4 !== void 0 && _this$devInfo4.isMatter);
377
386
  }
378
387
 
379
388
  /**
380
389
  * @description 是否是 涂鸦 Matter 设备
381
390
  */
382
391
  isTuyaMatterDevice(devInfo) {
383
- var _this$devInfo3, _this$devInfo4;
392
+ var _this$devInfo5, _this$devInfo6;
384
393
  if (devInfo) {
385
394
  return !!(devInfo !== null && devInfo !== void 0 && devInfo.isMatter && !(devInfo !== null && devInfo !== void 0 && devInfo.isTripartiteMatter));
386
395
  }
387
396
  this.devInfo = this.getCachedDevInfo();
388
- return !!((_this$devInfo3 = this.devInfo) !== null && _this$devInfo3 !== void 0 && _this$devInfo3.isMatter && !((_this$devInfo4 = this.devInfo) !== null && _this$devInfo4 !== void 0 && _this$devInfo4.isTripartiteMatter));
397
+ return !!((_this$devInfo5 = this.devInfo) !== null && _this$devInfo5 !== void 0 && _this$devInfo5.isMatter && !((_this$devInfo6 = this.devInfo) !== null && _this$devInfo6 !== void 0 && _this$devInfo6.isTripartiteMatter));
389
398
  }
390
399
 
391
400
  /**
392
401
  * @description 是否是 三方 Matter 设备
393
402
  */
394
403
  isTripartiteMatter(devInfo) {
395
- var _this$devInfo5;
404
+ var _this$devInfo7;
396
405
  if (devInfo) {
397
406
  return !!devInfo.isTripartiteMatter;
398
407
  }
399
408
  this.devInfo = this.getCachedDevInfo();
400
- return !!((_this$devInfo5 = this.devInfo) !== null && _this$devInfo5 !== void 0 && _this$devInfo5.isTripartiteMatter);
409
+ return !!((_this$devInfo7 = this.devInfo) !== null && _this$devInfo7 !== void 0 && _this$devInfo7.isTripartiteMatter);
401
410
  }
402
411
  }
@@ -88,6 +88,7 @@ describe('ScheduleSupport', () => {
88
88
  1: true
89
89
  },
90
90
  deviceList: [],
91
+ schema: [],
91
92
  panelConfig: {
92
93
  bic: [{
93
94
  code: 'timer',
@@ -135,7 +136,9 @@ describe('ScheduleSupport', () => {
135
136
  dps: {
136
137
  1: true
137
138
  },
138
- deviceList: []
139
+ deviceList: [{
140
+ devId: 'dev-1'
141
+ }]
139
142
  });
140
143
  getDpCodeByDpId.mockReturnValue('switch_led');
141
144
  getGroupInfo.mockImplementation(_ref2 => {
@@ -144,8 +147,19 @@ describe('ScheduleSupport', () => {
144
147
  } = _ref2;
145
148
  return success(groupInfo);
146
149
  });
150
+ getDeviceInfo.mockImplementation(_ref3 => {
151
+ let {
152
+ success
153
+ } = _ref3;
154
+ return success(baseDevInfo);
155
+ });
147
156
  await expect(support.init()).resolves.toBe(true);
148
- expect(setScheduleCache).toHaveBeenCalledWith('devInfo', groupInfo);
157
+ expect(setScheduleCache).toHaveBeenCalledWith('devInfo', expect.objectContaining({
158
+ groupId: 'group-1',
159
+ dps: {
160
+ 1: true
161
+ }
162
+ }));
149
163
  expect(setDpState).toHaveBeenCalledWith('switch_led', true);
150
164
  expect(devIdOrGroupIdCache.set).toHaveBeenCalledWith('', 'group-1');
151
165
  });
@@ -154,10 +168,10 @@ describe('ScheduleSupport', () => {
154
168
  devId: 'dev-1',
155
169
  groupId: undefined
156
170
  });
157
- getDeviceInfo.mockImplementation(_ref3 => {
171
+ getDeviceInfo.mockImplementation(_ref4 => {
158
172
  let {
159
173
  fail
160
- } = _ref3;
174
+ } = _ref4;
161
175
  setTimeout(() => fail(new Error('boom')), 0);
162
176
  });
163
177
  await expect(support.init()).rejects.toThrow('get dev info fail');
@@ -167,10 +181,10 @@ describe('ScheduleSupport', () => {
167
181
  devId: '',
168
182
  groupId: 'group-1'
169
183
  });
170
- getGroupInfo.mockImplementation(_ref4 => {
184
+ getGroupInfo.mockImplementation(_ref5 => {
171
185
  let {
172
186
  fail
173
- } = _ref4;
187
+ } = _ref5;
174
188
  setTimeout(() => fail(new Error('boom')), 0);
175
189
  });
176
190
  await expect(support.init()).rejects.toThrow('get group info fail');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-schedule-core",
3
- "version": "1.0.4-beta-12",
3
+ "version": "1.0.4-beta-13",
4
4
  "description": "照明计划模块核心能力",
5
5
  "main": "./lib/index.js",
6
6
  "files": [