Skip to content

Instantly share code, notes, and snippets.

@jameslafa
Last active December 21, 2015 06:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameslafa/1a2f33716dd8af6e3d08 to your computer and use it in GitHub Desktop.
Save jameslafa/1a2f33716dd8af6e3d08 to your computer and use it in GitHub Desktop.
AngularJS MixPanel mock for testing
/*
* author: @jameslafa
* More details on http://blog.james-lafa.fr/angularjs-how-to-mock-mixpanel-inside-for-your-tests/
*/
class MixpanelMock
debug = false
log: (event, data) ->
if @debug
console.log(event, data)
disable: () ->
@log("mixpanel.disable", arguments)
identify: () ->
@log("mixpanel.identify", arguments)
push: () ->
@log("mixpanel.push", arguments)
register: () ->
@log("mixpanel.register", arguments)
register_once: () ->
@log("mixpanel.register_once", arguments)
track: () ->
@log("mixpanel.track", arguments)
track_links: () ->
@log("mixpanel.track_links", arguments)
track_forms: () ->
@log("mixpanel.track_forms", arguments)
unregister: () ->
@log("mixpanel.unregister", arguments)
people:
set: () ->
@log("mixpanel.people.set", arguments)
set_once: () ->
@log("mixpanel.people.set_once", arguments)
increment: () ->
@log("mixpanel.people.increment", arguments)
append: () ->
@log("mixpanel.people.append", arguments)
track_charge: () ->
@log("mixpanel.people.track_charge", arguments)
clear_charges: () ->
@log("mixpanel.people.clear_charges", arguments)
delete_user: () ->
@log("mixpanel.people.delete_user", arguments)
window.mixpanel = new MixpanelMock()
@alec-c4
Copy link

alec-c4 commented Jun 27, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment