2013-11-08 15:06:27 -05:00
|
|
|
var notificationFixture = {
|
|
|
|
notification_type: 1, //mentioned
|
|
|
|
post_number: 1,
|
|
|
|
topic_id: 1234,
|
|
|
|
slug: "a-slug",
|
|
|
|
data: {
|
|
|
|
topic_title: "some title",
|
|
|
|
display_username: "velesin"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-30 17:53:14 -04:00
|
|
|
moduleFor("controller:notification");
|
2013-11-08 15:06:27 -05:00
|
|
|
|
|
|
|
test("scope property is correct", function() {
|
2014-07-30 17:53:14 -04:00
|
|
|
var controller = this.subject(notificationFixture);
|
2013-11-08 15:06:27 -05:00
|
|
|
equal(controller.get("scope"), "notifications.mentioned");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("username property is correct", function() {
|
2014-07-30 17:53:14 -04:00
|
|
|
var controller = this.subject(notificationFixture);
|
2013-11-08 15:06:27 -05:00
|
|
|
equal(controller.get("username"), "velesin");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("link property returns empty string when there is no topic title", function() {
|
|
|
|
var fixtureWithEmptyTopicTitle = _.extend({}, notificationFixture, {data: {topic_title: ""}});
|
2014-07-30 17:53:14 -04:00
|
|
|
var controller = this.subject(fixtureWithEmptyTopicTitle);
|
2013-11-08 15:06:27 -05:00
|
|
|
equal(controller.get("link"), "");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("link property returns correctly built link when there is a topic title", function() {
|
2014-07-30 17:53:14 -04:00
|
|
|
var controller = this.subject(notificationFixture);
|
|
|
|
ok(controller.get("link").indexOf('/t/a-slug/1234') !== -1, 'has the correct URL');
|
|
|
|
ok(controller.get("link").indexOf('some title') !== -1, 'has the correct title');
|
2013-11-08 15:06:27 -05:00
|
|
|
});
|