-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from edx/ahtesham/unit-tests-track-events
feat: add segment events unit tests
- Loading branch information
Showing
11 changed files
with
140 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createEventTracker, createPageEventTracker } from '../../../data/segment/utils'; | ||
import { | ||
categories, | ||
eventNames, | ||
forgotPasswordPageViewedEvent, | ||
trackForgotPasswordPageEvent, | ||
} from '../forgotpassword'; | ||
|
||
// Mock createEventTracker function | ||
jest.mock('../../../data/segment/utils', () => ({ | ||
createEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
createPageEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
})); | ||
|
||
describe('Tracking Functions', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should fire trackForgotPasswordPageEvent', () => { | ||
trackForgotPasswordPageEvent(); | ||
|
||
expect(createPageEventTracker).toHaveBeenCalledWith( | ||
eventNames.loginAndRegistration, | ||
'forgot-password', | ||
); | ||
}); | ||
|
||
it('should fire forgotPasswordPageViewedEvent', () => { | ||
forgotPasswordPageViewedEvent(); | ||
|
||
expect(createEventTracker).toHaveBeenCalledWith( | ||
eventNames.forgotPasswordPageViewd, | ||
{ category: categories.userEngagement }, | ||
); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
src/tracking/trackers/tests/progressive-profiling.test.jsx
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 { createEventTracker, createPageEventTracker } from '../../../data/segment/utils'; | ||
import { | ||
eventNames, | ||
trackProgressiveProfilingPageEvent, | ||
trackProgressiveProfilingSkipLinkClickEvent, | ||
} from '../progressive-profiling'; | ||
|
||
// Mock createEventTracker function | ||
jest.mock('../../../data/segment/utils', () => ({ | ||
createEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
createPageEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
})); | ||
|
||
describe('Tracking Functions', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should fire trackProgressiveProfilingSkipLinkClickEvent', () => { | ||
trackProgressiveProfilingSkipLinkClickEvent(); | ||
|
||
expect(createEventTracker).toHaveBeenCalledWith( | ||
eventNames.ProgressiveProfilingSkipLinkClick, | ||
{}, | ||
); | ||
}); | ||
|
||
it('should fire trackProgressiveProfilingPageEvent', () => { | ||
trackProgressiveProfilingPageEvent(); | ||
|
||
expect(createPageEventTracker).toHaveBeenCalledWith( | ||
eventNames.loginAndRegistration, | ||
'welcome', | ||
); | ||
}); | ||
}); |
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 { createEventTracker, createPageEventTracker } from '../../../data/segment/utils'; | ||
import { | ||
eventNames, | ||
registrationSuccessEvent, | ||
trackRegistrationPageEvent, | ||
} from '../register'; | ||
|
||
// Mock createEventTracker function | ||
jest.mock('../../../data/segment/utils', () => ({ | ||
createEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
createPageEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
})); | ||
|
||
describe('Tracking Functions', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should fire registrationSuccessEvent', () => { | ||
registrationSuccessEvent(); | ||
|
||
expect(createEventTracker).toHaveBeenCalledWith( | ||
eventNames.RegistrationSuccess, | ||
{}, | ||
); | ||
}); | ||
|
||
it('should fire trackRegistrationPageEvent', () => { | ||
trackRegistrationPageEvent(); | ||
|
||
expect(createPageEventTracker).toHaveBeenCalledWith( | ||
eventNames.loginAndRegistration, | ||
'register', | ||
); | ||
}); | ||
}); |
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,26 @@ | ||
import { createPageEventTracker } from '../../../data/segment/utils'; | ||
import { | ||
eventNames, | ||
trackResettPasswordPageEvent, | ||
} from '../reset-password'; | ||
|
||
// Mock createEventTracker function | ||
jest.mock('../../../data/segment/utils', () => ({ | ||
createEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
createPageEventTracker: jest.fn().mockImplementation(() => jest.fn()), | ||
})); | ||
|
||
describe('Tracking Functions', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should fire trackResettPasswordPageEvent', () => { | ||
trackResettPasswordPageEvent(); | ||
|
||
expect(createPageEventTracker).toHaveBeenCalledWith( | ||
eventNames.loginAndRegistration, | ||
'reset-password', | ||
); | ||
}); | ||
}); |