-
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.
chore(NativeMocks): Deprecate static instance method
- Loading branch information
1 parent
bf67932
commit e8e9a87
Showing
20 changed files
with
1,058 additions
and
169 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
import { GoogleAnalyticsMock } from './google-analytics'; | ||
|
||
describe('GoogleAnalytics', () => { | ||
let classUnderTest: any; | ||
|
||
beforeEach(() => { | ||
classUnderTest = new GoogleAnalyticsMock(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(classUnderTest).toBeDefined(); | ||
}); | ||
|
||
describe('startTrackerWithId', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.startTrackerWithId).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.startTrackerWithId().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('setAllowIDFACollection', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.setAllowIDFACollection).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.setAllowIDFACollection().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('setUserId', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.setUserId).toBeDefined(); | ||
}); | ||
|
||
it('should should return empty Promise', done => { | ||
classUnderTest.setUserId().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('setAnonymizeIp', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.setAnonymizeIp).toBeDefined(); | ||
}); | ||
|
||
it('should should return empty Promise', done => { | ||
classUnderTest.setAnonymizeIp().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('setAppVersion', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.setAppVersion).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.setAppVersion().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('setOptOut', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.setOptOut).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.setOptOut().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('debugMode', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.debugMode).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.debugMode().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('trackMetric', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.trackMetric).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.trackMetric().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('trackView', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.trackView).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.trackView().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('trackException', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.trackException).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.trackException().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('trackTiming', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.trackTiming).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.trackTiming().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('addTransaction', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.addTransaction).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.addTransaction().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('addTransactionItem', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.addTransactionItem).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.addTransactionItem().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('enableUncaughtExceptionReporting', () => { | ||
it('should be defined', () => { | ||
expect(classUnderTest.enableUncaughtExceptionReporting).toBeDefined(); | ||
}); | ||
|
||
it('should return empty Promise', done => { | ||
classUnderTest.enableUncaughtExceptionReporting().then(result => { | ||
expect(result).toBeUndefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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,41 +1,48 @@ | ||
export class GoogleAnalyticsMock { | ||
import deprecated from 'deprecated-decorator'; | ||
import { BaseMock } from '../base.mock'; | ||
|
||
public static instance(): any { | ||
let instance = jasmine.createSpyObj('GoogleAnalytics', [ | ||
'startTrackerWithId', | ||
'setAllowIDFACollection', | ||
'setUserId', | ||
'setAnonymizeIp', | ||
'setAppVersion', | ||
'setOptOut', | ||
'debugMode', | ||
'trackMetric', | ||
'trackView', | ||
'addCustomDimension', | ||
'trackEvent', | ||
'trackException', | ||
'trackTiming', | ||
'addTransaction', | ||
'addTransactionItem', | ||
'enableUncaughtExceptionReporting' | ||
]); | ||
instance.startTrackerWithId.and.returnValue(Promise.resolve()); | ||
instance.setAllowIDFACollection.and.returnValue(Promise.resolve()); | ||
instance.setUserId.and.returnValue(Promise.resolve()); | ||
instance.setAnonymizeIp.and.returnValue(Promise.resolve()); | ||
instance.setAppVersion.and.returnValue(Promise.resolve()); | ||
instance.setOptOut.and.returnValue(Promise.resolve()); | ||
instance.debugMode.and.returnValue(Promise.resolve()); | ||
instance.trackMetric.and.returnValue(Promise.resolve()); | ||
instance.trackView.and.returnValue(Promise.resolve()); | ||
instance.addCustomDimension.and.returnValue(Promise.resolve()); | ||
instance.trackEvent.and.returnValue(Promise.resolve()); | ||
instance.trackException.and.returnValue(Promise.resolve()); | ||
instance.trackTiming.and.returnValue(Promise.resolve()); | ||
instance.addTransaction.and.returnValue(Promise.resolve()); | ||
instance.addTransactionItem.and.returnValue(Promise.resolve()); | ||
instance.enableUncaughtExceptionReporting.and.returnValue(Promise.resolve()); | ||
const METHODS = [ | ||
'startTrackerWithId', | ||
'setAllowIDFACollection', | ||
'setUserId', | ||
'setAnonymizeIp', | ||
'setAppVersion', | ||
'setOptOut', | ||
'debugMode', | ||
'trackMetric', | ||
'trackView', | ||
'addCustomDimension', | ||
'trackEvent', | ||
'trackException', | ||
'trackTiming', | ||
'addTransaction', | ||
'addTransactionItem', | ||
'enableUncaughtExceptionReporting' | ||
]; | ||
|
||
return instance; | ||
export class GoogleAnalyticsMock extends BaseMock { | ||
constructor() { | ||
super('GoogleAnalytics', METHODS); | ||
this.spyObj.startTrackerWithId.and.returnValue(Promise.resolve()); | ||
this.spyObj.setAllowIDFACollection.and.returnValue(Promise.resolve()); | ||
this.spyObj.setUserId.and.returnValue(Promise.resolve()); | ||
this.spyObj.setAnonymizeIp.and.returnValue(Promise.resolve()); | ||
this.spyObj.setAppVersion.and.returnValue(Promise.resolve()); | ||
this.spyObj.setOptOut.and.returnValue(Promise.resolve()); | ||
this.spyObj.debugMode.and.returnValue(Promise.resolve()); | ||
this.spyObj.trackMetric.and.returnValue(Promise.resolve()); | ||
this.spyObj.trackView.and.returnValue(Promise.resolve()); | ||
this.spyObj.addCustomDimension.and.returnValue(Promise.resolve()); | ||
this.spyObj.trackEvent.and.returnValue(Promise.resolve()); | ||
this.spyObj.trackException.and.returnValue(Promise.resolve()); | ||
this.spyObj.trackTiming.and.returnValue(Promise.resolve()); | ||
this.spyObj.addTransaction.and.returnValue(Promise.resolve()); | ||
this.spyObj.addTransactionItem.and.returnValue(Promise.resolve()); | ||
this.spyObj.enableUncaughtExceptionReporting.and.returnValue(Promise.resolve()); | ||
} | ||
|
||
@deprecated('new GoogleAnalyticsMock()') | ||
static instance(): any { | ||
new GoogleAnalyticsMock(); | ||
} | ||
} |
Oops, something went wrong.