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
7121db0a
Commit
7121db0a
authored
Oct 09, 2013
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BLD-353: Fix js unit tests.
parent
79f11de6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
50 deletions
+45
-50
common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js
+34
-32
common/lib/xmodule/xmodule/js/spec/video/video_progress_slider_spec.js
+2
-4
common/lib/xmodule/xmodule/js/spec/video/video_quality_control_spec.js
+9
-14
No files found.
common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js
View file @
7121db0a
(
function
()
{
(
function
()
{
describe
(
'VideoCaption'
,
function
()
{
describe
(
'VideoCaption'
,
function
()
{
var
state
,
videoPlayer
,
videoCaption
,
videoSpeedControl
,
oldOTBD
;
var
state
,
videoPlayer
,
videoCaption
,
videoSpeedControl
,
oldOTBD
,
WAIT_TIMEOUT
=
1000
;
function
initialize
()
{
function
initialize
()
{
loadFixtures
(
'video_all.html'
);
loadFixtures
(
'video_all.html'
);
...
@@ -48,7 +49,7 @@
...
@@ -48,7 +49,7 @@
}
}
return
false
;
return
false
;
},
'Expect captions to be loaded.'
,
1000
);
},
'Expect captions to be loaded.'
,
WAIT_TIMEOUT
);
runs
(
function
()
{
runs
(
function
()
{
expect
(
$
.
ajaxWithPrefix
).
toHaveBeenCalledWith
({
expect
(
$
.
ajaxWithPrefix
).
toHaveBeenCalledWith
({
...
@@ -469,9 +470,7 @@
...
@@ -469,9 +470,7 @@
});
});
describe
(
'set the height of caption container'
,
function
()
{
describe
(
'set the height of caption container'
,
function
()
{
// Temporarily disabled due to intermittent failures
it
(
'when CC button is enabled'
,
function
()
{
// with error "Expected 745 to be close to 805, 2." in Firefox
xit
(
'when CC button is enabled'
,
function
()
{
var
realHeight
=
parseInt
(
var
realHeight
=
parseInt
(
$
(
'.subtitles'
).
css
(
'maxHeight'
),
10
$
(
'.subtitles'
).
css
(
'maxHeight'
),
10
),
),
...
@@ -576,12 +575,7 @@
...
@@ -576,12 +575,7 @@
$
(
'.subtitles li[data-start="14910"]'
).
trigger
(
'click'
);
$
(
'.subtitles li[data-start="14910"]'
).
trigger
(
'click'
);
});
});
// Temporarily disabled due to intermittent failures
it
(
'trigger seek event with the correct time'
,
function
()
{
// Fails with error: "InvalidStateError: An attempt was made to
// use an object that is not, or is no longer, usable
// Expected 0 to equal 14.91."
// on Firefox
xit
(
'trigger seek event with the correct time'
,
function
()
{
expect
(
videoPlayer
.
currentTime
).
toEqual
(
14.91
);
expect
(
videoPlayer
.
currentTime
).
toEqual
(
14.91
);
});
});
});
});
...
@@ -763,33 +757,41 @@
...
@@ -763,33 +757,41 @@
});
});
});
});
xdescribe
(
'when enter key is pressed on a caption'
,
function
()
{
describe
(
'when enter key is pressed on a caption'
,
function
()
{
var
subDataLiIdx__0
;
beforeEach
(
function
()
{
var
assertCaptions
=
function
(
expectations
)
{
var
e
;
subDataLiIdx__0
=
$
(
'.subtitles li[data-index=0]'
);
waitsFor
(
function
()
{
return
videoCaption
.
captions
.
length
;
},
"Captions are not loaded."
,
WAIT_TIMEOUT
);
spyOn
(
videoCaption
,
'seekPlayer'
).
andCallThrough
();
runs
(
expectations
);
videoCaption
.
isMouseFocus
=
false
;
},
subDataLiIdx__0
.
trigger
(
jQuery
.
Event
(
'focus'
));
initializeClick
=
function
()
{
e
=
jQuery
.
Event
(
'keydown'
);
var
e
,
e
.
which
=
13
;
// ENTER key
subDataLiIdx__0
=
$
(
'.subtitles li[data-index=0]'
);
subDataLiIdx__0
.
trigger
(
e
);
});
spyOn
(
videoCaption
,
'seekPlayer'
).
andCallThrough
();
videoCaption
.
isMouseFocus
=
false
;
subDataLiIdx__0
.
trigger
(
jQuery
.
Event
(
'focus'
));
e
=
jQuery
.
Event
(
'keydown'
);
e
.
which
=
13
;
// ENTER key
subDataLiIdx__0
.
trigger
(
e
);
};
// Temporarily disabled due to intermittent failures.
it
(
'shows an outline around it'
,
function
()
{
//
assertCaptions
(
function
()
{
// Fails with error: "InvalidStateError: InvalidStateError: An
var
subDataLiIdx__0
=
$
(
'.subtitles li[data-index=0]'
);
// attempt was made to use an object that is not, or is no
initializeClick
();
// longer, usable".
expect
(
subDataLiIdx__0
).
toHaveClass
(
'focused'
);
xit
(
'shows an outline around it'
,
function
()
{
});
expect
(
subDataLiIdx__0
).
toHaveClass
(
'focused'
);
});
});
xit
(
'calls seekPlayer'
,
function
()
{
it
(
'calls seekPlayer'
,
function
()
{
expect
(
videoCaption
.
seekPlayer
).
toHaveBeenCalled
();
assertCaptions
(
function
()
{
initializeClick
();
expect
(
videoCaption
.
seekPlayer
).
toHaveBeenCalled
();
});
});
});
});
});
});
});
...
...
common/lib/xmodule/xmodule/js/spec/video/video_progress_slider_spec.js
View file @
7121db0a
...
@@ -154,7 +154,7 @@
...
@@ -154,7 +154,7 @@
// function might (and probably will) fail.
// function might (and probably will) fail.
oldSetTimeout
=
window
.
setTimeout
;
oldSetTimeout
=
window
.
setTimeout
;
// Redefine window.setTimeout() function as a spy.
// Redefine window.setTimeout() function as a spy.
window
.
setTimeout
=
jasmine
.
createSpy
().
andCallFake
(
function
(
callback
,
timeout
)
{
return
5
;
})
window
.
setTimeout
=
jasmine
.
createSpy
().
andCallFake
(
function
(
callback
,
timeout
)
{
return
5
;
})
;
window
.
setTimeout
.
andReturn
(
100
);
window
.
setTimeout
.
andReturn
(
100
);
initialize
();
initialize
();
...
@@ -180,9 +180,7 @@
...
@@ -180,9 +180,7 @@
expect
(
videoPlayer
.
currentTime
).
toEqual
(
20
);
expect
(
videoPlayer
.
currentTime
).
toEqual
(
20
);
});
});
// Temporarily disabled due to intermittent failures
it
(
'set timeout to unfreeze the slider'
,
function
()
{
// Fails with error: " Expected true to be falsy."
xit
(
'set timeout to unfreeze the slider'
,
function
()
{
expect
(
window
.
setTimeout
).
toHaveBeenCalledWith
(
jasmine
.
any
(
Function
),
200
);
expect
(
window
.
setTimeout
).
toHaveBeenCalledWith
(
jasmine
.
any
(
Function
),
200
);
window
.
setTimeout
.
mostRecentCall
.
args
[
0
]();
window
.
setTimeout
.
mostRecentCall
.
args
[
0
]();
expect
(
videoProgressSlider
.
frozen
).
toBeFalsy
();
expect
(
videoProgressSlider
.
frozen
).
toBeFalsy
();
...
...
common/lib/xmodule/xmodule/js/spec/video/video_quality_control_spec.js
View file @
7121db0a
...
@@ -11,7 +11,9 @@
...
@@ -11,7 +11,9 @@
beforeEach
(
function
()
{
beforeEach
(
function
()
{
oldOTBD
=
window
.
onTouchBasedDevice
;
oldOTBD
=
window
.
onTouchBasedDevice
;
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
).
andReturn
(
false
);
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
)
.
andReturn
(
false
);
});
});
afterEach
(
function
()
{
afterEach
(
function
()
{
...
@@ -20,7 +22,8 @@
...
@@ -20,7 +22,8 @@
});
});
describe
(
'constructor'
,
function
()
{
describe
(
'constructor'
,
function
()
{
var
oldYT
=
window
.
YT
;
var
oldYT
=
window
.
YT
,
SELECTOR
=
'a.quality_control'
;
beforeEach
(
function
()
{
beforeEach
(
function
()
{
window
.
YT
=
{
window
.
YT
=
{
...
@@ -37,21 +40,13 @@
...
@@ -37,21 +40,13 @@
});
});
it
(
'render the quality control'
,
function
()
{
it
(
'render the quality control'
,
function
()
{
expect
(
videoControl
.
secondaryControlsEl
.
html
())
var
container
=
videoControl
.
secondaryControlsEl
;
.
toContain
(
expect
(
container
).
toContain
(
SELECTOR
);
'<a '
+
'href="#" '
+
'class="quality_control" '
+
'title="HD off" '
+
'role="button" '
+
'aria-disabled="false"'
+
'>HD off</a>'
);
});
});
it
(
'bind the quality control'
,
function
()
{
it
(
'bind the quality control'
,
function
()
{
expect
(
$
(
'.quality_control'
))
var
handler
=
videoQualityControl
.
toggleQuality
;
.
toHandleWith
(
'click'
,
videoQualityControl
.
toggleQuality
);
expect
(
$
(
SELECTOR
)).
toHandleWith
(
'click'
,
handler
);
});
});
});
});
});
});
...
...
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