discourse/test/javascripts/models/user-stream-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.1 KiB
JavaScript
Raw Normal View History

import UserAction from "discourse/models/user-action";
2019-11-13 15:55:32 -05:00
import User from "discourse/models/user";
2019-11-13 15:55:32 -05:00
QUnit.module("model: UserStream");
2017-06-14 13:57:58 -04:00
QUnit.test("basics", (assert) => {
2019-11-13 15:55:32 -05:00
var user = User.create({ id: 1, username: "eviltrout" });
2013-07-26 17:09:54 -04:00
var stream = user.get("stream");
2017-06-14 13:57:58 -04:00
assert.present(stream, "a user has a stream by default");
assert.equal(stream.get("user"), user, "the stream points back to the user");
2013-07-26 17:09:54 -04:00
2017-06-14 13:57:58 -04:00
assert.equal(stream.get("itemsLoaded"), 0, "no items are loaded by default");
assert.blank(stream.get("content"), "no content by default");
assert.blank(stream.get("filter"), "no filter by default");
2013-07-26 17:09:54 -04:00
2017-06-14 13:57:58 -04:00
assert.ok(!stream.get("loaded"), "the stream is not loaded by default");
2013-07-26 17:09:54 -04:00
});
2017-06-14 13:57:58 -04:00
QUnit.test("filterParam", (assert) => {
2019-11-13 15:55:32 -05:00
var user = User.create({ id: 1, username: "eviltrout" });
2013-07-26 17:09:54 -04:00
var stream = user.get("stream");
2014-09-10 21:15:49 -04:00
// defaults to posts/topics
2017-06-14 13:57:58 -04:00
assert.equal(stream.get("filterParam"), "4,5");
2013-07-26 17:09:54 -04:00
stream.set("filter", UserAction.TYPES.likes_given);
assert.equal(stream.get("filterParam"), UserAction.TYPES.likes_given);
2013-07-26 17:09:54 -04:00
stream.set("filter", UserAction.TYPES.replies);
2017-06-14 13:57:58 -04:00
assert.equal(stream.get("filterParam"), "6,9");
});