-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding feature to trackEvents from outside of webplayer
- Loading branch information
Showing
6 changed files
with
137 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
const ApiManager = require('../../src/APIManager'); | ||
const Instance = require('../mocks/DeviceRenderer'); | ||
const Clipboard = require('../../src/plugins/Clipboard'); | ||
const store = require('../../src/store/index'); | ||
|
||
let apiManager; | ||
let instance; | ||
let exposedApiFunctions; | ||
|
||
describe('APIManager', () => { | ||
beforeEach(() => { | ||
instance = new Instance({}); | ||
apiManager = new ApiManager(instance); | ||
exposedApiFunctions = apiManager.getExposedApiFunctions(); | ||
store(instance); | ||
|
||
new Clipboard(instance, { | ||
CLIPBOARD_TITLE: 'TEST CLIPBOARD PLUGIN TITLE', | ||
}); | ||
}); | ||
|
||
describe('has exposed api', () => { | ||
test('getRegisteredFunctions', () => { | ||
const registeredFunctions = exposedApiFunctions.utils.getRegisteredFunctions(); | ||
expect(Object.keys(registeredFunctions)).toEqual( | ||
expect.arrayContaining([ | ||
'sendData', | ||
'getRegisteredFunctions', | ||
'addEventListener', | ||
'disconnect', | ||
'enableTrackEvents', | ||
'trackEvents', | ||
]), | ||
); | ||
}); | ||
|
||
test('sendTrackEvent', () => { | ||
let events = []; | ||
|
||
exposedApiFunctions.analytics.enableTrackEvents(true); | ||
|
||
// attach callback to get events | ||
exposedApiFunctions.analytics.trackEvents((evts) => { | ||
events = evts; | ||
}); | ||
|
||
const button = document.getElementsByClassName('gm-clipboard-button')[0]; | ||
expect(button).toBeTruthy(); | ||
button.click(); | ||
|
||
// expect object to be exactly the same | ||
expect(events).toEqual([{category: 'widget', action: 'open', name: 'Clipboard'}]); | ||
}); | ||
}); | ||
}); |