-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type checking tests after move to sources. This closes #11
- Loading branch information
Showing
10 changed files
with
112 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,51 @@ | ||
import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser'; | ||
import { setBaseTestProviders } from 'angular2/testing'; | ||
import { IonicApp, Platform } from 'ionic-framework/ionic'; | ||
import { ClickerApp } from '../app/app'; | ||
import { ClickerApp } from './app'; | ||
|
||
// this needs doing _once_ for the entire test suite, hence it's here | ||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); | ||
|
||
let clickerApp = null; | ||
let clickerApp: ClickerApp = null; | ||
|
||
function getComponentStub(name) { | ||
let component = { | ||
setRoot: function() { return true; }, | ||
close: function(root) { return true; }, | ||
function getComponentStub(name: string): any { | ||
'use strict'; | ||
|
||
let component: Object = { | ||
setRoot: function(): boolean { return true; }, | ||
close: function(root: any): boolean { return true; }, | ||
}; | ||
return component; | ||
} | ||
|
||
export function main() { | ||
export function main(): void { | ||
'use strict'; | ||
|
||
describe('ClickerApp', () => { | ||
|
||
beforeEach(function() { | ||
let ionicApp = new IonicApp(null, null, null); | ||
let platform = new Platform(); | ||
beforeEach(() => { | ||
let ionicApp: IonicApp = new IonicApp(null, null, null); | ||
let platform: Platform = new Platform(); | ||
clickerApp = new ClickerApp(ionicApp, platform); | ||
}); | ||
|
||
it('initialises with two possible pages', () => { | ||
expect(clickerApp.pages.length).toEqual(2); | ||
expect(clickerApp['pages'].length).toEqual(2); | ||
}); | ||
|
||
it('initialises with a root page', () => { | ||
expect(clickerApp.rootPage).not.toBe(null); | ||
expect(clickerApp['rootPage']).not.toBe(null); | ||
}); | ||
|
||
it('initialises with an app', () => { | ||
expect(clickerApp.app).not.toBe(null); | ||
expect(clickerApp['app']).not.toBe(null); | ||
}); | ||
|
||
it('opens a page', () => { | ||
spyOn(clickerApp.app, 'getComponent').and.callFake(getComponentStub); | ||
clickerApp.openPage(clickerApp.pages[1]); | ||
expect(clickerApp.app.getComponent).toHaveBeenCalledWith('leftMenu'); | ||
expect(clickerApp.app.getComponent).toHaveBeenCalledWith('nav'); | ||
spyOn(clickerApp['app'], 'getComponent').and.callFake(getComponentStub); | ||
clickerApp.openPage(clickerApp['pages'][1]); | ||
expect(clickerApp['app'].getComponent).toHaveBeenCalledWith('leftMenu'); | ||
expect(clickerApp['app'].getComponent).toHaveBeenCalledWith('nav'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.