-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ToastController): Deprecate static instance method
- Loading branch information
1 parent
b35bc05
commit cb1b348
Showing
2 changed files
with
48 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ToastControllerMock } from './toast-controller'; | ||
import { ToastMock } from './toast'; | ||
|
||
describe('ToastController', () => { | ||
let classUnderTest: any; | ||
|
||
beforeEach(() => { | ||
classUnderTest = new ToastControllerMock(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(classUnderTest).toBeDefined(); | ||
}); | ||
|
||
describe('create', () => { | ||
it('should exist', () => { | ||
expect(classUnderTest.create).toBeDefined(); | ||
}); | ||
|
||
it('should return a Toast', () => { | ||
let result = classUnderTest.create(); | ||
|
||
expect(result).toBeDefined(); | ||
expect(result.present).toBeDefined(); | ||
}); | ||
|
||
it('should return provided Toast', () => { | ||
let toast = new ToastMock(); | ||
classUnderTest = new ToastControllerMock(toast); | ||
|
||
let result = classUnderTest.create(); | ||
|
||
expect(result).toBe(toast); | ||
}); | ||
}); | ||
}); |
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,11 +1,17 @@ | ||
import {ToastMock} from './toast'; | ||
import deprecated from 'deprecated-decorator'; | ||
import { BaseMock } from '../base.mock'; | ||
import { ToastMock } from './toast'; | ||
|
||
export class ToastControllerMock { | ||
public static instance(toast?: ToastMock): any { | ||
const METHODS = ['create']; | ||
|
||
let instance = jasmine.createSpyObj('ToastController', ['create']); | ||
instance.create.and.returnValue(toast || ToastMock.instance()); | ||
export class ToastControllerMock extends BaseMock { | ||
constructor(toast?: ToastMock) { | ||
super('ToastController', METHODS); | ||
this.spyObj.create.and.returnValue(toast || new ToastMock()); | ||
} | ||
|
||
return instance; | ||
@deprecated('new ToastControllerMock()') | ||
public static instance(toast?: ToastMock): any { | ||
return new ToastControllerMock(toast); | ||
} | ||
} |