submessage: Replace bogus test data with valid objects.

The test data was not the correct representation of submessage's
content field. This caused the zod schema to throw error.

This is a temporary solution and eventually we have to move to an
efficient approach making the test data more representative and
accurate.

Discussion:
https://chat.zulip.org/#narrow/stream/6-frontend/topic/TypeScript.20migration/near/1766122
This commit is contained in:
Varun Singh 2024-03-28 12:54:44 +05:30 committed by Tim Abbott
parent f1db30418b
commit 894756addc
1 changed files with 31 additions and 5 deletions

View File

@ -23,8 +23,12 @@ run_test("get_message_events", () => {
assert.equal(submessage.get_message_events(msg), undefined);
const submessages = [
{id: 222, sender_id: 99, content: "84"},
{id: 9, sender_id: 33, content: "42"},
{id: 222, sender_id: 99, content: '{"type":"new_option","idx":1,"option":"bar"}'},
{
id: 9,
sender_id: 33,
content: '{"widget_type": "poll", "extra_data": {"question": "foo", "options": []}}',
},
];
msg = {
@ -37,8 +41,24 @@ run_test("get_message_events", () => {
submessages,
};
assert.deepEqual(submessage.get_message_events(msg), [
{sender_id: 33, data: 42},
{sender_id: 99, data: 84},
{
sender_id: 33,
data: {
widget_type: "poll",
extra_data: {
question: "foo",
options: [],
},
},
},
{
sender_id: 99,
data: {
type: "new_option",
idx: 1,
option: "bar",
},
},
]);
});
@ -73,7 +93,13 @@ run_test("check sender", ({override}) => {
const message = {
id: message_id,
sender_id: 1,
submessages: [{sender_id: 2, content: "{}"}],
submessages: [
{
sender_id: 2,
content:
'{"widget_type": "poll", "extra_data": {"question": "foo", "options": []}}',
},
],
};
override(message_store, "get", (arg) => {