2013-12-02 13:15:31 -05:00
|
|
|
var smallLogoUrl = "/assets/logo-single.png",
|
|
|
|
bigLogoUrl = "/assets/logo.png",
|
|
|
|
smallLogoSelector = "img.logo-small",
|
|
|
|
bigLogoSelector = "img#site-logo.logo-big",
|
2013-12-09 16:27:49 -05:00
|
|
|
homeIconSelector = "i.fa-home",
|
2013-12-02 13:15:31 -05:00
|
|
|
headerSelector = "h2#site-text-logo.text-logo";
|
2013-10-30 16:56:48 -04:00
|
|
|
|
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
function setSmallLogoUrl(url) {
|
2013-10-30 16:56:48 -04:00
|
|
|
Discourse.SiteSettings.logo_small_url = url;
|
2013-12-02 13:15:31 -05:00
|
|
|
}
|
2013-10-30 16:56:48 -04:00
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
function setBigLogoUrl(url) {
|
2013-10-30 16:56:48 -04:00
|
|
|
Discourse.SiteSettings.logo_url = url;
|
2013-12-02 13:15:31 -05:00
|
|
|
}
|
2013-10-30 16:56:48 -04:00
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
function setTitle(title) {
|
2013-10-30 16:56:48 -04:00
|
|
|
Discourse.SiteSettings.title = title;
|
2013-12-02 13:15:31 -05:00
|
|
|
}
|
2013-10-30 16:56:48 -04:00
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
function setMobileView(value) {
|
2013-10-30 16:56:48 -04:00
|
|
|
Discourse.Mobile.mobileView = value;
|
2013-12-02 13:15:31 -05:00
|
|
|
}
|
2013-10-30 16:56:48 -04:00
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
var view;
|
|
|
|
function setMinimized(value) {
|
2013-10-30 16:56:48 -04:00
|
|
|
Ember.run(function() {
|
|
|
|
view.set("minimized", value);
|
|
|
|
});
|
2013-12-02 13:15:31 -05:00
|
|
|
}
|
2013-10-30 16:56:48 -04:00
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
function appendView() {
|
2013-10-30 16:56:48 -04:00
|
|
|
Ember.run(function() {
|
2013-11-08 14:23:29 -05:00
|
|
|
view.appendTo(fixture());
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
2013-12-02 13:15:31 -05:00
|
|
|
}
|
2013-10-30 16:56:48 -04:00
|
|
|
|
2013-12-02 13:15:31 -05:00
|
|
|
var oldMobileView;
|
2013-11-19 11:59:50 -05:00
|
|
|
module("Discourse.HomeLogoComponent", {
|
2013-10-30 16:56:48 -04:00
|
|
|
setup: function() {
|
|
|
|
oldMobileView = Discourse.Mobile.mobileView;
|
2013-12-02 13:15:31 -05:00
|
|
|
|
|
|
|
view = Ember.View.create({
|
|
|
|
container: Discourse.__container__,
|
|
|
|
template: Ember.Handlebars.compile("{{home-logo minimized=view.minimized}}")
|
|
|
|
});
|
2013-10-30 16:56:48 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
|
|
|
Discourse.Mobile.mobileView = oldMobileView;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test("displays small logo when 'minimized' version is chosen and application is not in mobile mode", function() {
|
|
|
|
setMobileView(false);
|
|
|
|
setMinimized(true);
|
|
|
|
|
|
|
|
appendView();
|
|
|
|
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(smallLogoSelector)), "small logo image is present");
|
2013-11-12 15:21:02 -05:00
|
|
|
equal(fixture(smallLogoSelector).attr("src"), smallLogoUrl, "small logo image has correct source");
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(!exists(fixture(homeIconSelector)), "default home icon is not present");
|
|
|
|
ok(!exists(fixture(bigLogoSelector)), "big logo image is not present");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("displays default home icon when small logo image should be displayed but its url is not configured", function() {
|
|
|
|
setMobileView(false);
|
|
|
|
setMinimized(true);
|
|
|
|
setSmallLogoUrl("");
|
|
|
|
|
|
|
|
appendView();
|
|
|
|
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(homeIconSelector)), "default home icon is present");
|
|
|
|
ok(!exists(fixture(smallLogoSelector)), "small logo image is not present");
|
|
|
|
ok(!exists(fixture(bigLogoSelector)), "big logo image is not present");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("displays big logo when 'minimized' version is not chosen", function() {
|
|
|
|
setMobileView(false);
|
|
|
|
setMinimized(false);
|
|
|
|
|
|
|
|
appendView();
|
|
|
|
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(bigLogoSelector)), "big logo image is present");
|
|
|
|
ok(!exists(fixture(smallLogoSelector)), "small logo image is not present");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("displays big logo when application is in mobile mode", function() {
|
|
|
|
setMobileView(true);
|
|
|
|
setMinimized(true);
|
|
|
|
|
|
|
|
appendView();
|
|
|
|
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(bigLogoSelector)), "big logo image is present");
|
|
|
|
ok(!exists(fixture(smallLogoSelector)), "small logo image is not present");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("displays big logo image with alt title when big logo url is configured", function() {
|
|
|
|
setMobileView(true);
|
|
|
|
setMinimized(false);
|
|
|
|
setTitle("site-title");
|
|
|
|
|
|
|
|
appendView();
|
|
|
|
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(bigLogoSelector)), "big logo image is present");
|
2013-11-12 15:21:02 -05:00
|
|
|
equal(fixture(bigLogoSelector).attr("src"), bigLogoUrl, "big logo image has correct source");
|
2013-11-08 14:23:29 -05:00
|
|
|
equal(fixture(bigLogoSelector).attr("alt"), "site-title", "big logo image has correct alt text");
|
|
|
|
ok(!exists(fixture(headerSelector)), "header with title is not present");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("displays header with site title when big logo image should be displayed but its url is not configured", function() {
|
|
|
|
setMobileView(true);
|
|
|
|
setMinimized(false);
|
|
|
|
setTitle("site-title");
|
|
|
|
setBigLogoUrl("");
|
|
|
|
|
|
|
|
appendView();
|
|
|
|
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(headerSelector)), "header with title is present");
|
|
|
|
equal(fixture(headerSelector).text(), "site-title", "header with title has correct text");
|
|
|
|
ok(!exists(fixture(bigLogoSelector)), "big logo image is not present");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("dynamically toggles logo size when 'minimized' property changes", function() {
|
|
|
|
setMobileView(false);
|
|
|
|
setMinimized(true);
|
|
|
|
|
|
|
|
appendView();
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(smallLogoSelector)), "initially small logo is shown");
|
2013-10-30 16:56:48 -04:00
|
|
|
|
|
|
|
setMinimized(false);
|
2013-11-08 14:23:29 -05:00
|
|
|
ok(exists(fixture(bigLogoSelector)), "when 'minimized' version is turned off, small logo is replaced with the big one");
|
2013-10-30 16:56:48 -04:00
|
|
|
});
|