mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
This run_test helper sets up a convention that allows us to give really short tracebacks for errors, and eventually we can have more control over running individual tests. (The latter goal has some complications, since we often intentionally leak setup in tests.)
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
zrequire('muting');
|
|
|
|
run_test('edge_cases', () => {
|
|
// private messages
|
|
assert(!muting.is_topic_muted(undefined, undefined));
|
|
|
|
// defensive
|
|
assert(!muting.is_topic_muted('nonexistent', undefined));
|
|
});
|
|
|
|
run_test('basics', () => {
|
|
assert(!muting.is_topic_muted('devel', 'java'));
|
|
muting.add_muted_topic('devel', 'java');
|
|
assert(muting.is_topic_muted('devel', 'java'));
|
|
|
|
// test idempotentcy
|
|
muting.add_muted_topic('devel', 'java');
|
|
assert(muting.is_topic_muted('devel', 'java'));
|
|
|
|
muting.remove_muted_topic('devel', 'java');
|
|
assert(!muting.is_topic_muted('devel', 'java'));
|
|
|
|
// test idempotentcy
|
|
muting.remove_muted_topic('devel', 'java');
|
|
assert(!muting.is_topic_muted('devel', 'java'));
|
|
|
|
// test unknown stream is harmless too
|
|
muting.remove_muted_topic('unknown', 'java');
|
|
assert(!muting.is_topic_muted('unknown', 'java'));
|
|
});
|
|
|
|
run_test('get_and_set_muted_topics', () => {
|
|
assert.deepEqual(muting.get_muted_topics(), []);
|
|
muting.add_muted_topic('office', 'gossip');
|
|
muting.add_muted_topic('devel', 'java');
|
|
assert.deepEqual(muting.get_muted_topics().sort(), [
|
|
['devel', 'java'],
|
|
['office', 'gossip'],
|
|
]);
|
|
|
|
muting.set_muted_topics([
|
|
['social', 'breakfast'],
|
|
['design', 'typography'],
|
|
]);
|
|
assert.deepEqual(muting.get_muted_topics().sort(), [
|
|
['design', 'typography'],
|
|
['social', 'breakfast'],
|
|
]);
|
|
});
|
|
|
|
run_test('case_insensitivity', () => {
|
|
muting.set_muted_topics([]);
|
|
assert(!muting.is_topic_muted('SOCial', 'breakfast'));
|
|
muting.set_muted_topics([
|
|
['SOCial', 'breakfast'],
|
|
]);
|
|
assert(muting.is_topic_muted('SOCial', 'breakfast'));
|
|
assert(muting.is_topic_muted('social', 'breakfast'));
|
|
assert(muting.is_topic_muted('social', 'breakFAST'));
|
|
});
|