typing_status: Make some test cases slightly less artificial.

All these cases are meant to simulate having a user actually typing a
message to some actual recipients, so the `conversation_is_valid`
parameter would be true.

We make this change so that in an upcoming change that eliminates this
parameter, the adjustments to the test cases can be highly regular and
we don't have to introduce a new wrinkle to correspond to these values
being false.
This commit is contained in:
Greg Price 2019-10-21 17:02:32 -07:00
parent 3bdd741852
commit dcccef9b3a
1 changed files with 5 additions and 4 deletions

View File

@ -266,6 +266,7 @@ run_test('basics', () => {
const call_count = {
maybe_ping_server: 0,
actually_ping_server: 0,
start_or_extend_idle_timer: 0,
stop_last_notification: 0,
};
@ -280,12 +281,12 @@ run_test('basics', () => {
// User ids of poeple in compose narrow doesn't change and is same as stat.current_recipent
// so counts of function should increase except stop_last_notification
typing_status.handle_text_input(worker, typing.get_recipient(), false);
typing_status.handle_text_input(worker, typing.get_recipient(), true);
assert.deepEqual(call_count.maybe_ping_server, 1);
assert.deepEqual(call_count.start_or_extend_idle_timer, 1);
assert.deepEqual(call_count.stop_last_notification, 0);
typing_status.handle_text_input(worker, typing.get_recipient(), false);
typing_status.handle_text_input(worker, typing.get_recipient(), true);
assert.deepEqual(call_count.maybe_ping_server, 2);
assert.deepEqual(call_count.start_or_extend_idle_timer, 2);
assert.deepEqual(call_count.stop_last_notification, 0);
@ -293,8 +294,8 @@ run_test('basics', () => {
// change in recipient and new_recipient should make us
// call typing_status.stop_last_notification
compose_pm_pill.get_user_ids_string = () => '2,3,4';
typing_status.handle_text_input(worker, typing.get_recipient(), false);
typing_status.handle_text_input(worker, typing.get_recipient(), true);
assert.deepEqual(call_count.maybe_ping_server, 2);
assert.deepEqual(call_count.start_or_extend_idle_timer, 2);
assert.deepEqual(call_count.start_or_extend_idle_timer, 3);
assert.deepEqual(call_count.stop_last_notification, 1);
});