Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
305e9315
Commit
305e9315
authored
Jun 18, 2013
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write Jasmine tests to prove Segment.io works in Logger
parent
f528f61e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
common/static/coffee/spec/logger_spec.coffee
+25
-2
common/templates/jasmine/jasmine_test_runner.html.erb
+1
-0
No files found.
common/static/coffee/spec/logger_spec.coffee
View file @
305e9315
describe
'Logger'
,
->
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'
,
->
it
'expose window.log_event'
,
->
expect
(
window
.
log_event
).
toBe
Logger
.
log
expect
(
window
.
log_event
).
toBe
Logger
.
log
describe
'log'
,
->
describe
'log'
,
->
it
'send event to Segment.io if event is whitelisted'
,
->
it
'sends an event to Segment.io, if the event is whitelisted'
,
->
spyOn
'analytics.track'
Logger
.
log
'seq_goto'
,
'data'
Logger
.
log
'seq_goto'
,
'data'
expect
(
analytics
.
track
).
toHaveBeenCalledWith
'seq_goto'
,
'data'
expect
(
analytics
.
track
).
toHaveBeenCalledWith
'seq_goto'
,
'data'
...
@@ -16,6 +28,17 @@ describe 'Logger', ->
...
@@ -16,6 +28,17 @@ describe 'Logger', ->
event
:
'"data"'
event
:
'"data"'
page
:
window
.
location
.
href
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.
# Broken with commit 9f75e64? Skipping for now.
xdescribe
'bind'
,
->
xdescribe
'bind'
,
->
beforeEach
->
beforeEach
->
...
...
common/templates/jasmine/jasmine_test_runner.html.erb
View file @
305e9315
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/tiny_mce/tiny_mce.js"
></script>
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/tiny_mce/tiny_mce.js"
></script>
<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/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/jquery.timeago.js"
></script>
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/sinon-1.7.1.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
AjaxPrefix
.
addAjaxPrefix
(
jQuery
,
function
()
{
AjaxPrefix
.
addAjaxPrefix
(
jQuery
,
function
()
{
return
""
;
return
""
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment