diff --git a/src/angular/haptic.spec.ts b/src/angular/haptic.spec.ts new file mode 100644 index 0000000..bfb5029 --- /dev/null +++ b/src/angular/haptic.spec.ts @@ -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(); + }); + }); +}); diff --git a/src/angular/haptic.ts b/src/angular/haptic.ts index 65a2a5c..07bb8e8 100644 --- a/src/angular/haptic.ts +++ b/src/angular/haptic.ts @@ -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(); } }