Skip to content

Commit 8c2078c

Browse files
author
Sean McBride
committed
Reorganize eventdispatchertest.js and add tests for class names after multiple loads.
1 parent ecea6d9 commit 8c2078c

File tree

1 file changed

+100
-11
lines changed

1 file changed

+100
-11
lines changed

src-test/core/eventdispatchertest.js

Lines changed: 100 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ EventDispatcherTest.prototype.testClassNamesOnActiveLoad = function() {
5151
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
5252
};
5353

54+
EventDispatcherTest.prototype.testEventsOnActiveLoad = function() {
55+
this.eventDispatcher_.dispatchLoading();
56+
assertTrue(this.loadingEventCalled_);
57+
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
58+
assertTrue(this.fontLoadingEventCalled_);
59+
assertEquals('fontFamilyLoading n4', this.fontLoading_);
60+
this.eventDispatcher_.dispatchFontActive('fontFamilyActive', 'n4');
61+
assertTrue(this.fontActiveEventCalled_);
62+
assertEquals('fontFamilyActive n4', this.fontActive_);
63+
this.eventDispatcher_.dispatchActive();
64+
assertTrue(this.activeEventCalled_);
65+
};
66+
5467
EventDispatcherTest.prototype.testClassNamesOnInactiveFontButActive = function() {
5568
this.eventDispatcher_.dispatchLoading();
5669
assertEquals('ns-loading', this.fakeHtmlElement_.className);
@@ -62,19 +75,30 @@ EventDispatcherTest.prototype.testClassNamesOnInactiveFontButActive = function()
6275
assertEquals('ns-myfamily-n4-inactive ns-active', this.fakeHtmlElement_.className);
6376
};
6477

65-
EventDispatcherTest.prototype.testEventsOnActiveLoad = function() {
78+
EventDispatcherTest.prototype.testEventsOnInactiveFontButActive = function() {
6679
this.eventDispatcher_.dispatchLoading();
6780
assertTrue(this.loadingEventCalled_);
6881
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
6982
assertTrue(this.fontLoadingEventCalled_);
7083
assertEquals('fontFamilyLoading n4', this.fontLoading_);
71-
this.eventDispatcher_.dispatchFontActive('fontFamilyActive', 'n4');
72-
assertTrue(this.fontActiveEventCalled_);
73-
assertEquals('fontFamilyActive n4', this.fontActive_);
84+
this.eventDispatcher_.dispatchFontInactive('fontFamilyInactive', 'n4');
85+
assertTrue(this.fontInactvieEventCalled_);
86+
assertEquals('fontFamilyInactive n4', this.fontInactive_);
7487
this.eventDispatcher_.dispatchActive();
7588
assertTrue(this.activeEventCalled_);
7689
};
7790

91+
EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
92+
this.eventDispatcher_.dispatchLoading();
93+
assertEquals('ns-loading', this.fakeHtmlElement_.className);
94+
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
95+
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
96+
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
97+
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
98+
this.eventDispatcher_.dispatchInactive();
99+
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
100+
};
101+
78102
EventDispatcherTest.prototype.testEventsOnInactiveLoad = function() {
79103
this.eventDispatcher_.dispatchLoading();
80104
assertTrue(this.loadingEventCalled_);
@@ -84,11 +108,21 @@ EventDispatcherTest.prototype.testEventsOnInactiveLoad = function() {
84108
this.eventDispatcher_.dispatchFontInactive('fontFamilyInactive', 'n4');
85109
assertTrue(this.fontInactvieEventCalled_);
86110
assertEquals('fontFamilyInactive n4', this.fontInactive_);
87-
this.eventDispatcher_.dispatchActive();
88-
assertTrue(this.activeEventCalled_);
111+
this.eventDispatcher_.dispatchInactive();
112+
assertTrue(this.inactiveEventCalled_);
89113
};
90114

91-
EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
115+
EventDispatcherTest.prototype.testClassNamesOnInactive = function() {
116+
this.eventDispatcher_.dispatchInactive();
117+
assertEquals('ns-inactive', this.fakeHtmlElement_.className);
118+
};
119+
120+
EventDispatcherTest.prototype.testEventsOnInactive = function() {
121+
this.eventDispatcher_.dispatchInactive();
122+
assertTrue(this.inactiveEventCalled_);
123+
};
124+
125+
EventDispatcherTest.prototype.testClassNamesOnInactiveThenActiveLoad = function() {
92126
this.eventDispatcher_.dispatchLoading();
93127
assertEquals('ns-loading', this.fakeHtmlElement_.className);
94128
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
@@ -97,14 +131,69 @@ EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
97131
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
98132
this.eventDispatcher_.dispatchInactive();
99133
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
134+
this.eventDispatcher_.dispatchLoading();
135+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
136+
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
137+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
138+
this.eventDispatcher_.dispatchFontActive('My Family 2', 'n4');
139+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
140+
this.eventDispatcher_.dispatchActive();
141+
assertEquals('ns-myfamily-n4-inactive ns-myfamily2-n4-active ns-active', this.fakeHtmlElement_.className);
100142
};
101143

102-
EventDispatcherTest.prototype.testClassNamesOnInactive = function() {
144+
EventDispatcherTest.prototype.testClassNamesOnActiveThenInactiveLoad = function() {
145+
this.eventDispatcher_.dispatchLoading();
146+
assertEquals('ns-loading', this.fakeHtmlElement_.className);
147+
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
148+
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
149+
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
150+
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
151+
this.eventDispatcher_.dispatchActive();
152+
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
153+
this.eventDispatcher_.dispatchLoading();
154+
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
155+
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
156+
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
157+
this.eventDispatcher_.dispatchFontInactive('My Family 2', 'n4');
158+
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
103159
this.eventDispatcher_.dispatchInactive();
104-
assertEquals('ns-inactive', this.fakeHtmlElement_.className);
160+
assertEquals('ns-myfamily-n4-active ns-active ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
105161
};
106162

107-
EventDispatcherTest.prototype.testEventsOnInactive = function() {
163+
EventDispatcherTest.prototype.testClassNamesOnActiveThenActiveLoad = function() {
164+
this.eventDispatcher_.dispatchLoading();
165+
assertEquals('ns-loading', this.fakeHtmlElement_.className);
166+
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
167+
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
168+
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
169+
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
170+
this.eventDispatcher_.dispatchActive();
171+
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
172+
this.eventDispatcher_.dispatchLoading();
173+
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
174+
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
175+
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
176+
this.eventDispatcher_.dispatchFontActive('My Family 2', 'n4');
177+
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
178+
this.eventDispatcher_.dispatchActive();
179+
assertEquals('ns-myfamily-n4-active ns-active ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
180+
};
181+
182+
EventDispatcherTest.prototype.testClassNamesOnInactiveThenInactiveLoad = function() {
183+
this.eventDispatcher_.dispatchLoading();
184+
assertEquals('ns-loading', this.fakeHtmlElement_.className);
185+
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
186+
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
187+
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
188+
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
108189
this.eventDispatcher_.dispatchInactive();
109-
assertTrue(this.inactiveEventCalled_);
190+
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
191+
this.eventDispatcher_.dispatchLoading();
192+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
193+
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
194+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
195+
this.eventDispatcher_.dispatchFontInactive('My Family 2', 'n4');
196+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
197+
this.eventDispatcher_.dispatchInactive();
198+
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
110199
};

0 commit comments

Comments
 (0)