Skip to content

Commit

Permalink
Reorganize eventdispatchertest.js and add tests for class names after…
Browse files Browse the repository at this point in the history
… multiple loads.
  • Loading branch information
Sean McBride committed Nov 20, 2010
1 parent ecea6d9 commit 8c2078c
Showing 1 changed file with 100 additions and 11 deletions.
111 changes: 100 additions & 11 deletions src-test/core/eventdispatchertest.js
Expand Up @@ -51,6 +51,19 @@ EventDispatcherTest.prototype.testClassNamesOnActiveLoad = function() {
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testEventsOnActiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertTrue(this.loadingEventCalled_);
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
assertTrue(this.fontLoadingEventCalled_);
assertEquals('fontFamilyLoading n4', this.fontLoading_);
this.eventDispatcher_.dispatchFontActive('fontFamilyActive', 'n4');
assertTrue(this.fontActiveEventCalled_);
assertEquals('fontFamilyActive n4', this.fontActive_);
this.eventDispatcher_.dispatchActive();
assertTrue(this.activeEventCalled_);
};

EventDispatcherTest.prototype.testClassNamesOnInactiveFontButActive = function() {
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-loading', this.fakeHtmlElement_.className);
Expand All @@ -62,19 +75,30 @@ EventDispatcherTest.prototype.testClassNamesOnInactiveFontButActive = function()
assertEquals('ns-myfamily-n4-inactive ns-active', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testEventsOnActiveLoad = function() {
EventDispatcherTest.prototype.testEventsOnInactiveFontButActive = function() {
this.eventDispatcher_.dispatchLoading();
assertTrue(this.loadingEventCalled_);
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
assertTrue(this.fontLoadingEventCalled_);
assertEquals('fontFamilyLoading n4', this.fontLoading_);
this.eventDispatcher_.dispatchFontActive('fontFamilyActive', 'n4');
assertTrue(this.fontActiveEventCalled_);
assertEquals('fontFamilyActive n4', this.fontActive_);
this.eventDispatcher_.dispatchFontInactive('fontFamilyInactive', 'n4');
assertTrue(this.fontInactvieEventCalled_);
assertEquals('fontFamilyInactive n4', this.fontInactive_);
this.eventDispatcher_.dispatchActive();
assertTrue(this.activeEventCalled_);
};

EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchInactive();
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testEventsOnInactiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertTrue(this.loadingEventCalled_);
Expand All @@ -84,11 +108,21 @@ EventDispatcherTest.prototype.testEventsOnInactiveLoad = function() {
this.eventDispatcher_.dispatchFontInactive('fontFamilyInactive', 'n4');
assertTrue(this.fontInactvieEventCalled_);
assertEquals('fontFamilyInactive n4', this.fontInactive_);
this.eventDispatcher_.dispatchActive();
assertTrue(this.activeEventCalled_);
this.eventDispatcher_.dispatchInactive();
assertTrue(this.inactiveEventCalled_);
};

EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
EventDispatcherTest.prototype.testClassNamesOnInactive = function() {
this.eventDispatcher_.dispatchInactive();
assertEquals('ns-inactive', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testEventsOnInactive = function() {
this.eventDispatcher_.dispatchInactive();
assertTrue(this.inactiveEventCalled_);
};

EventDispatcherTest.prototype.testClassNamesOnInactiveThenActiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
Expand All @@ -97,14 +131,69 @@ EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchInactive();
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontActive('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchActive();
assertEquals('ns-myfamily-n4-inactive ns-myfamily2-n4-active ns-active', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testClassNamesOnInactive = function() {
EventDispatcherTest.prototype.testClassNamesOnActiveThenInactiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchActive();
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontInactive('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchInactive();
assertEquals('ns-inactive', this.fakeHtmlElement_.className);
assertEquals('ns-myfamily-n4-active ns-active ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testEventsOnInactive = function() {
EventDispatcherTest.prototype.testClassNamesOnActiveThenActiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchActive();
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontActive('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchActive();
assertEquals('ns-myfamily-n4-active ns-active ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
};

EventDispatcherTest.prototype.testClassNamesOnInactiveThenInactiveLoad = function() {
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchInactive();
assertTrue(this.inactiveEventCalled_);
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchLoading();
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchFontInactive('My Family 2', 'n4');
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
this.eventDispatcher_.dispatchInactive();
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
};

0 comments on commit 8c2078c

Please sign in to comment.