2017-06-14 12:57:58 -05:00
|
|
|
QUnit.module("Discourse.UserStream");
|
2015-08-11 11:27:07 -05:00
|
|
|
|
2017-06-14 12:57:58 -05:00
|
|
|
QUnit.test('basics', assert =>{
|
2013-07-26 16:09:54 -05:00
|
|
|
var user = Discourse.User.create({id: 1, username: 'eviltrout'});
|
|
|
|
var stream = user.get('stream');
|
2017-06-14 12:57:58 -05: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 16:09:54 -05:00
|
|
|
|
2017-06-14 12:57:58 -05: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 16:09:54 -05:00
|
|
|
|
2017-06-14 12:57:58 -05:00
|
|
|
assert.ok(!stream.get('loaded'), "the stream is not loaded by default");
|
2013-07-26 16:09:54 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-14 12:57:58 -05:00
|
|
|
QUnit.test('filterParam', assert => {
|
2013-07-26 16:09:54 -05:00
|
|
|
var user = Discourse.User.create({id: 1, username: 'eviltrout'});
|
|
|
|
var stream = user.get('stream');
|
|
|
|
|
2014-09-10 20:15:49 -05:00
|
|
|
// defaults to posts/topics
|
2017-06-14 12:57:58 -05:00
|
|
|
assert.equal(stream.get('filterParam'), "4,5");
|
2013-07-26 16:09:54 -05:00
|
|
|
|
|
|
|
stream.set('filter', Discourse.UserAction.TYPES.likes_given);
|
2017-06-14 12:57:58 -05:00
|
|
|
assert.equal(stream.get('filterParam'), Discourse.UserAction.TYPES.likes_given);
|
2013-07-26 16:09:54 -05:00
|
|
|
|
|
|
|
stream.set('filter', Discourse.UserAction.TYPES.replies);
|
2017-06-14 12:57:58 -05:00
|
|
|
assert.equal(stream.get('filterParam'), '6,9');
|
2013-07-26 16:09:54 -05:00
|
|
|
|
2017-06-14 12:57:58 -05:00
|
|
|
});
|