2019-11-09 01:52:39 +08:00
|
|
|
import UserAction from "discourse/models/user-action";
|
2019-11-14 04:55:32 +08:00
|
|
|
import User from "discourse/models/user";
|
2019-11-09 01:52:39 +08:00
|
|
|
|
2019-11-14 04:55:32 +08:00
|
|
|
QUnit.module("model: UserStream");
|
2015-08-12 00:27:07 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("basics", assert => {
|
2019-11-14 04:55:32 +08:00
|
|
|
var user = User.create({ id: 1, username: "eviltrout" });
|
2018-06-15 23:03:24 +08:00
|
|
|
var stream = user.get("stream");
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.present(stream, "a user has a stream by default");
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(stream.get("user"), user, "the stream points back to the user");
|
2013-07-27 05:09:54 +08:00
|
|
|
|
2018-06-15 23:03:24 +08: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-27 05:09:54 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.ok(!stream.get("loaded"), "the stream is not loaded by default");
|
2013-07-27 05:09:54 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
QUnit.test("filterParam", assert => {
|
2019-11-14 04:55:32 +08:00
|
|
|
var user = User.create({ id: 1, username: "eviltrout" });
|
2018-06-15 23:03:24 +08:00
|
|
|
var stream = user.get("stream");
|
2013-07-27 05:09:54 +08:00
|
|
|
|
2014-09-11 09:15:49 +08:00
|
|
|
// defaults to posts/topics
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(stream.get("filterParam"), "4,5");
|
2013-07-27 05:09:54 +08:00
|
|
|
|
2019-11-09 01:52:39 +08:00
|
|
|
stream.set("filter", UserAction.TYPES.likes_given);
|
|
|
|
assert.equal(stream.get("filterParam"), UserAction.TYPES.likes_given);
|
2013-07-27 05:09:54 +08:00
|
|
|
|
2019-11-09 01:52:39 +08:00
|
|
|
stream.set("filter", UserAction.TYPES.replies);
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(stream.get("filterParam"), "6,9");
|
|
|
|
});
|