mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
refactors logo component unit tests to use fixture helper
This commit is contained in:
parent
965a0a91a2
commit
db002e9294
@ -36,14 +36,10 @@ var headerSelector = "h2#site-text-logo.text-logo";
|
||||
|
||||
var appendView = function() {
|
||||
Ember.run(function() {
|
||||
view.appendTo(Ember.$("#qunit-fixture"));
|
||||
view.appendTo(fixture());
|
||||
});
|
||||
};
|
||||
|
||||
var exists = function(selector) {
|
||||
return Ember.$(selector).length > 0;
|
||||
};
|
||||
|
||||
|
||||
module("Discourse.DiscourseLogoComponent", {
|
||||
setup: function() {
|
||||
@ -66,10 +62,10 @@ test("displays small logo when 'minimized' version is chosen and application is
|
||||
|
||||
appendView();
|
||||
|
||||
ok(exists(smallLogoSelector), "small logo image is present");
|
||||
equal(Ember.$(smallLogoSelector).attr("src"), "small-logo-url", "small logo image has correct source");
|
||||
ok(!exists(homeIconSelector), "default home icon is not present");
|
||||
ok(!exists(bigLogoSelector), "big logo image is not present");
|
||||
ok(exists(fixture(smallLogoSelector)), "small logo image is present");
|
||||
equal(fixture(smallLogoSelector).attr("src"), "small-logo-url", "small logo image has correct source");
|
||||
ok(!exists(fixture(homeIconSelector)), "default home icon is not present");
|
||||
ok(!exists(fixture(bigLogoSelector)), "big logo image is not present");
|
||||
});
|
||||
|
||||
test("displays default home icon when small logo image should be displayed but its url is not configured", function() {
|
||||
@ -79,9 +75,9 @@ test("displays default home icon when small logo image should be displayed but i
|
||||
|
||||
appendView();
|
||||
|
||||
ok(exists(homeIconSelector), "default home icon is present");
|
||||
ok(!exists(smallLogoSelector), "small logo image is not present");
|
||||
ok(!exists(bigLogoSelector), "big logo image is not present");
|
||||
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");
|
||||
});
|
||||
|
||||
test("displays big logo when 'minimized' version is not chosen", function() {
|
||||
@ -90,8 +86,8 @@ test("displays big logo when 'minimized' version is not chosen", function() {
|
||||
|
||||
appendView();
|
||||
|
||||
ok(exists(bigLogoSelector), "big logo image is present");
|
||||
ok(!exists(smallLogoSelector), "small logo image is not present");
|
||||
ok(exists(fixture(bigLogoSelector)), "big logo image is present");
|
||||
ok(!exists(fixture(smallLogoSelector)), "small logo image is not present");
|
||||
});
|
||||
|
||||
test("displays big logo when application is in mobile mode", function() {
|
||||
@ -100,8 +96,8 @@ test("displays big logo when application is in mobile mode", function() {
|
||||
|
||||
appendView();
|
||||
|
||||
ok(exists(bigLogoSelector), "big logo image is present");
|
||||
ok(!exists(smallLogoSelector), "small logo image is not present");
|
||||
ok(exists(fixture(bigLogoSelector)), "big logo image is present");
|
||||
ok(!exists(fixture(smallLogoSelector)), "small logo image is not present");
|
||||
});
|
||||
|
||||
test("displays big logo image with alt title when big logo url is configured", function() {
|
||||
@ -111,10 +107,10 @@ test("displays big logo image with alt title when big logo url is configured", f
|
||||
|
||||
appendView();
|
||||
|
||||
ok(exists(bigLogoSelector), "big logo image is present");
|
||||
equal(Ember.$(bigLogoSelector).attr("src"), "big-logo-url", "big logo image has correct source");
|
||||
equal(Ember.$(bigLogoSelector).attr("alt"), "site-title", "big logo image has correct alt text");
|
||||
ok(!exists(headerSelector), "header with title is not present");
|
||||
ok(exists(fixture(bigLogoSelector)), "big logo image is present");
|
||||
equal(fixture(bigLogoSelector).attr("src"), "big-logo-url", "big logo image has correct source");
|
||||
equal(fixture(bigLogoSelector).attr("alt"), "site-title", "big logo image has correct alt text");
|
||||
ok(!exists(fixture(headerSelector)), "header with title is not present");
|
||||
});
|
||||
|
||||
test("displays header with site title when big logo image should be displayed but its url is not configured", function() {
|
||||
@ -125,9 +121,9 @@ test("displays header with site title when big logo image should be displayed bu
|
||||
|
||||
appendView();
|
||||
|
||||
ok(exists(headerSelector), "header with title is present");
|
||||
equal(Ember.$(headerSelector).text(), "site-title", "header with title has correct text");
|
||||
ok(!exists(bigLogoSelector), "big logo image is not present");
|
||||
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");
|
||||
});
|
||||
|
||||
test("dynamically toggles logo size when 'minimized' property changes", function() {
|
||||
@ -135,14 +131,14 @@ test("dynamically toggles logo size when 'minimized' property changes", function
|
||||
setMinimized(true);
|
||||
|
||||
appendView();
|
||||
ok(exists(smallLogoSelector), "initially small logo is shown");
|
||||
ok(exists(fixture(smallLogoSelector)), "initially small logo is shown");
|
||||
|
||||
setMinimized(false);
|
||||
ok(exists(bigLogoSelector), "when 'minimized' version is turned off, small logo is replaced with the big one");
|
||||
ok(exists(fixture(bigLogoSelector)), "when 'minimized' version is turned off, small logo is replaced with the big one");
|
||||
});
|
||||
|
||||
test("links logo to the site root", function() {
|
||||
appendView();
|
||||
|
||||
equal(Ember.$(".title > a").attr("href"), "/");
|
||||
equal(fixture(".title > a").attr("href"), "/");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user