feat: 更新 buildRowsFromPayload 函数以根据 is_send 字段条件返回房间状态行,并添加相应的单元测试

This commit is contained in:
2026-03-24 20:04:01 +08:00
parent 59a49df66d
commit e083e77768
2 changed files with 8 additions and 1 deletions

View File

@@ -223,7 +223,7 @@ export const buildRowsFromPayload = (rawPayload) => {
return {
registerRows: [registerRow],
roomStatusRows: [roomStatusUpdateRow]
roomStatusRows: registerRow.is_send === 0 ? [roomStatusUpdateRow] : []
};
};

View File

@@ -36,6 +36,13 @@ describe('Register Processor', () => {
expect(rows.roomStatusRows[0].hotel_id).toBe(0);
});
it('should skip room_status updates when is_send is not 0', () => {
const rows = buildRowsFromPayload({ ...basePayload, is_send: 1 });
expect(rows.registerRows).toHaveLength(1);
expect(rows.registerRows[0].is_send).toBe(1);
expect(rows.roomStatusRows).toHaveLength(0);
});
it('should convert udp_raw byte array to base64 text', () => {
const rows = buildRowsFromPayload({
...basePayload,