2013-11-08 15:06:27 -05:00
|
|
|
var controller;
|
|
|
|
var notificationFixture = {
|
|
|
|
notification_type: 1, //mentioned
|
|
|
|
post_number: 1,
|
|
|
|
topic_id: 1234,
|
|
|
|
slug: "a-slug",
|
|
|
|
data: {
|
|
|
|
topic_title: "some title",
|
|
|
|
display_username: "velesin"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-12 14:01:21 -04:00
|
|
|
module("controller:notification", {
|
2013-11-08 15:06:27 -05:00
|
|
|
setup: function() {
|
2014-05-12 14:01:21 -04:00
|
|
|
controller = testController('notification', notificationFixture);
|
2013-11-08 15:06:27 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test("scope property is correct", function() {
|
|
|
|
equal(controller.get("scope"), "notifications.mentioned");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("username property is correct", function() {
|
|
|
|
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: ""}});
|
|
|
|
Ember.run(function() {
|
|
|
|
controller.set("content", fixtureWithEmptyTopicTitle);
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(controller.get("link"), "");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("link property returns correctly built link when there is a topic title", function() {
|
|
|
|
var $link = $(controller.get("link"));
|
|
|
|
|
2014-06-11 20:59:07 -04:00
|
|
|
equal($link.attr("href"), "/t/a-slug/1234", "generated link points to a correct URL");
|
2013-11-08 15:06:27 -05:00
|
|
|
equal($link.text(), "some title", "generated link has correct text");
|
|
|
|
});
|