Fix broken JS tests.

This commit is contained in:
Guo Xiang Tan 2017-09-26 16:15:25 +08:00
parent c25730935e
commit 793ccd144e
2 changed files with 7 additions and 4 deletions

View File

@ -17,13 +17,9 @@ QUnit.test('updateFromJson', assert => {
var details = buildDetails(1234);
details.updateFromJson({
suggested_topics: [{id: 1}, {id: 3}],
allowed_users: [{username: 'eviltrout'}]
});
assert.equal(details.get('suggested_topics.length'), 2, 'it loaded the suggested_topics');
assert.containsInstance(details.get('suggested_topics'), Topic);
assert.equal(details.get('allowed_users.length'), 1, 'it loaded the allowed users');
assert.containsInstance(details.get('allowed_users'), Discourse.User);

View File

@ -24,6 +24,13 @@ QUnit.test('has a postStream', assert => {
assert.equal(postStream.get('topic'), topic, "the postStream has a reference back to the topic");
});
QUnit.test('has suggestedTopics', assert => {
const topic = Topic.create({ suggested_topics: [{ id: 1 }, { id: 2 }] });
const suggestedTopics = topic.get('suggestedTopics');
assert.equal(suggestedTopics.length, 2, 'it loaded the suggested_topics');
assert.containsInstance(suggestedTopics, Topic);
});
QUnit.test('category relationship', assert => {
// It finds the category by id