2013-11-09 04:06:27 +08: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-31 05:53:14 +08:00
|
|
|
moduleFor("controller:notification");
|
2013-11-09 04:06:27 +08:00
|
|
|
|
|
|
|
test("scope property is correct", function() {
|
2014-07-31 05:53:14 +08:00
|
|
|
var controller = this.subject(notificationFixture);
|
2013-11-09 04:06:27 +08:00
|
|
|
equal(controller.get("scope"), "notifications.mentioned");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("username property is correct", function() {
|
2014-07-31 05:53:14 +08:00
|
|
|
var controller = this.subject(notificationFixture);
|
2013-11-09 04:06:27 +08:00
|
|
|
equal(controller.get("username"), "velesin");
|
|
|
|
});
|
|
|
|
|
2014-08-06 05:36:37 +08:00
|
|
|
test("description property returns badge name when there is one", function() {
|
|
|
|
var fixtureWithBadgeName = _.extend({}, notificationFixture, { data: { badge_name: "badge" } });
|
|
|
|
var controller = this.subject(fixtureWithBadgeName);
|
|
|
|
equal(controller.get("description"), "badge");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("description property returns empty string when there is no topic title", function() {
|
|
|
|
var fixtureWithEmptyTopicTitle = _.extend({}, notificationFixture, { data: { topic_title: "" } });
|
2014-07-31 05:53:14 +08:00
|
|
|
var controller = this.subject(fixtureWithEmptyTopicTitle);
|
2014-08-06 05:36:37 +08:00
|
|
|
equal(controller.get("description"), "");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("description property returns topic title", function() {
|
|
|
|
var fixtureWithTopicTitle = _.extend({}, notificationFixture, { data: { topic_title: "topic" } });
|
|
|
|
var controller = this.subject(fixtureWithTopicTitle);
|
|
|
|
equal(controller.get("description"), "topic");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("url property returns badge's url when there is a badge", function() {
|
|
|
|
var fixtureWithBadge = _.extend({}, notificationFixture, { data: { badge_id: 1, badge_name: "Badge Name"} });
|
|
|
|
var controller = this.subject(fixtureWithBadge);
|
|
|
|
equal(controller.get("url"), "/badges/1/badge-name");
|
2013-11-09 04:06:27 +08:00
|
|
|
});
|
|
|
|
|
2014-08-06 05:36:37 +08:00
|
|
|
test("url property returns topic's url when there is a topic", function() {
|
2014-07-31 05:53:14 +08:00
|
|
|
var controller = this.subject(notificationFixture);
|
2014-08-06 05:36:37 +08:00
|
|
|
equal(controller.get("url"), "/t/a-slug/1234");
|
2013-11-09 04:06:27 +08:00
|
|
|
});
|