Skip to content

Commit

Permalink
node tests: Introduce test wrapper in pm_conversations.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijeetbodas2001 authored and timabbott committed Apr 29, 2021
1 parent 4a91d5f commit 6769990
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions frontend_tests/node_tests/pm_conversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const {run_test} = require("../zjsunit/test");
const people = zrequire("people");
const pmc = zrequire("pm_conversations");

function initialize_recents(params) {
pmc.clear_for_testing();
pmc.recent.initialize(params);
function test(label, f) {
run_test(label, (override) => {
pmc.clear_for_testing();
people.initialize_current_user(15);
f(override);
});
}

run_test("partners", () => {
test("partners", () => {
const user1_id = 1;
const user2_id = 2;
const user3_id = 3;
Expand All @@ -26,16 +29,15 @@ run_test("partners", () => {
assert.equal(pmc.is_partner(user3_id), true);
});

run_test("insert_recent_private_message", () => {
test("insert_recent_private_message", () => {
const params = {
recent_private_conversations: [
{user_ids: [11, 2], max_message_id: 150},
{user_ids: [1], max_message_id: 111},
{user_ids: [], max_message_id: 7},
],
};
people.initialize_current_user(15);
initialize_recents(params);
pmc.recent.initialize(params);

assert.deepEqual(pmc.recent.get(), [
{user_ids_string: "2,11", max_message_id: 150},
Expand Down

0 comments on commit 6769990

Please sign in to comment.