Commit 841ff476 by Renzo Lucioni

Abridge tests in light of learning how Segment.io works

parent 305e9315
describe 'Logger', ->
beforeEach ->
window.analytics = jasmine.createSpyObj('analytics', ['track'])
analytics.track.andCallFake(->
$.ajax('/foo');
)
@requests = requests = []
@xhr = sinon.useFakeXMLHttpRequest()
@xhr.onCreate = (xhr) -> requests.push(xhr)
afterEach ->
@xhr.restore()
delete window.analytics
it 'expose window.log_event', ->
expect(window.log_event).toBe Logger.log
describe 'log', ->
it 'sends an event to Segment.io, if the event is whitelisted', ->
spyOn(analytics, 'track')
Logger.log 'seq_goto', 'data'
expect(analytics.track).toHaveBeenCalledWith 'seq_goto', 'data'
......@@ -28,17 +16,6 @@ describe 'Logger', ->
event: '"data"'
page: window.location.href
it 'continues to log events if Segment.io is down', ->
spyOn($, 'getWithPrefix').andCallThrough()
Logger.log 'seq_goto', 'data'
expect(@requests.length).toEqual 2
expect(@requests[0].url).toMatch /foo/
@requests[0].respond(500)
expect($.getWithPrefix).toHaveBeenCalledWith '/event',
event_type: 'seq_goto'
event: '"data"'
page: window.location.href
# Broken with commit 9f75e64? Skipping for now.
xdescribe 'bind', ->
beforeEach ->
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -27,6 +27,7 @@
<script type="text/javascript" src="<%= common_js_root %>/vendor/mathjax-MathJax-c9db6ac/MathJax.js?config=default"></script>
<script type="text/javascript" src="<%= common_js_root %>/vendor/jquery.timeago.js"></script>
<script type="text/javascript" src="<%= common_js_root %>/vendor/sinon-1.7.1.js"></script>
<script type="text/javascript" src="<%= common_js_root %>/vendor/analytics.js"></script>
<script type="text/javascript">
AjaxPrefix.addAjaxPrefix(jQuery, function() {
return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment