Skip to content

Commit

Permalink
refactor(Haptic): Deprecate static instance method
Browse files Browse the repository at this point in the history
  • Loading branch information
stonelasley committed Jul 5, 2018
1 parent 5ca7662 commit 554eb7b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 12 deletions.
59 changes: 59 additions & 0 deletions src/angular/haptic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { HapticMock } from './haptic';

describe('Haptic', () => {
let classUnderTest: any;

beforeEach(() => {
classUnderTest = new HapticMock();
});

it('should be defined', () => {
expect(classUnderTest).toBeDefined();
});

describe('available', () => {
it('should be defined', () => {
expect(classUnderTest.available).toBeDefined();
});

it('should be true', () => {
expect(classUnderTest.available()).toBe(true);
});
});

describe('gestureSelectionChanged', () => {
it('should be defined', () => {
expect(classUnderTest.gestureSelectionChanged).toBeDefined();
});
});

describe('gestureSelectionEnd', () => {
it('should be defined', () => {
expect(classUnderTest.gestureSelectionEnd).toBeDefined();
});
});

describe('gestureSelectionStart', () => {
it('should be defined', () => {
expect(classUnderTest.gestureSelectionStart).toBeDefined();
});
});

describe('impact', () => {
it('should be defined', () => {
expect(classUnderTest.impact).toBeDefined();
});
});

describe('notification', () => {
it('should be defined', () => {
expect(classUnderTest.notification).toBeDefined();
});
});

describe('selection', () => {
it('should be defined', () => {
expect(classUnderTest.selection).toBeDefined();
});
});
});
33 changes: 21 additions & 12 deletions src/angular/haptic.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
export class HapticMock {
public static instance(): any {
let instance = jasmine.createSpyObj('Haptic', ['available',
'gestureSelectionChanged',
'gestureSelectionEnd',
'gestureSelectionStart',
'impact',
'notification',
'selection'
]);
instance.available.and.returnValue(true);
import { BaseMock } from '../base.mock';
import { deprecated } from 'deprecated-decorator';

const METHODS = [
'available',
'gestureSelectionChanged',
'gestureSelectionEnd',
'gestureSelectionStart',
'impact',
'notification',
'selection'
];

return instance;
export class HapticMock extends BaseMock {
constructor() {
super('Haptic', METHODS);
this.spyObj.available.and.returnValue(true);
}

@deprecated('new HapticMock()')
public static instance(): any {
return new HapticMock();
}
}

0 comments on commit 554eb7b

Please sign in to comment.