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
73011383
Commit
73011383
authored
Oct 14, 2013
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add js unit tests.
parent
eeab7847
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
0 deletions
+111
-0
common/lib/xmodule/xmodule/js/spec/video/resizer_spec.js
+94
-0
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
+17
-0
No files found.
common/lib/xmodule/xmodule/js/spec/video/resizer_spec.js
0 → 100644
View file @
73011383
(
function
(
requirejs
,
require
,
define
)
{
require
(
[
'video/00_resizer.js'
],
function
(
Resizer
)
{
describe
(
'Resizer'
,
function
()
{
var
config
,
container
,
element
;
beforeEach
(
function
()
{
var
html
=
[
'<div class="rszr-wrapper" style="width:200px; height: 200px;">'
,
'<div class="rszr-el" style="width:100px; height: 150px;">'
,
'Content'
,
'</div>'
,
'</div>'
].
join
(
''
);
setFixtures
(
html
);
container
=
$
(
'.rszr-wrapper'
);
element
=
$
(
'.rszr-el'
);
config
=
{
container
:
container
,
element
:
element
};
});
it
(
'When Initialize without required parameters, log message is shown'
,
function
()
{
spyOn
(
console
,
'log'
);
new
Resizer
({
});
expect
(
console
.
log
).
toHaveBeenCalled
();
}
);
it
(
'`alignByWidthOnly` works correctly'
,
function
()
{
var
resizer
=
new
Resizer
(
config
).
alignByWidthOnly
(),
expectedWidth
=
container
.
width
(),
realWidth
=
element
.
width
();
expect
(
realWidth
).
toBe
(
expectedWidth
);
});
it
(
'`alignByHeightOnly` works correctly'
,
function
()
{
var
resizer
=
new
Resizer
(
config
).
alignByHeightOnly
(),
expectedHeight
=
container
.
height
(),
realHeight
=
element
.
height
(),
realWidth
;
expect
(
realHeight
).
toBe
(
expectedHeight
);
});
it
(
'`align` works correctly'
,
function
()
{
var
resizer
=
new
Resizer
(
config
).
align
(),
expectedHeight
=
container
.
height
(),
realHeight
=
element
.
height
(),
expectedWidth
=
50
;
// conatinerRatio >= elementRatio
expect
(
realHeight
).
toBe
(
expectedHeight
);
// conatinerRatio < elementRatio
container
.
width
(
expectedWidth
);
resizer
.
align
();
realWidth
=
element
.
width
();
expect
(
realWidth
).
toBe
(
expectedWidth
);
});
it
(
'`setMode` works correctly'
,
function
()
{
var
resizer
=
new
Resizer
(
config
).
setMode
(
'height'
),
expectedHeight
=
container
.
height
(),
realHeight
=
element
.
height
(),
expectedWidth
=
50
;
// conatinerRatio >= elementRatio
expect
(
realHeight
).
toBe
(
expectedHeight
);
// conatinerRatio < elementRatio
container
.
width
(
expectedWidth
);
resizer
.
setMode
(
'width'
);
realWidth
=
element
.
width
();
expect
(
realWidth
).
toBe
(
expectedWidth
);
});
});
});
}(
RequireJS
.
requirejs
,
RequireJS
.
require
,
RequireJS
.
define
));
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
View file @
73011383
...
...
@@ -10,6 +10,8 @@
}
state
=
new
Video
(
'#example'
);
state
.
videoEl
=
$
(
'video, iframe'
);
videoPlayer
=
state
.
videoPlayer
;
player
=
videoPlayer
.
player
;
videoControl
=
state
.
videoControl
;
...
...
@@ -17,6 +19,19 @@
videoProgressSlider
=
state
.
videoProgressSlider
;
videoSpeedControl
=
state
.
videoSpeedControl
;
videoVolumeControl
=
state
.
videoVolumeControl
;
state
.
resizer
=
(
function
()
{
var
methods
=
[
'align'
,
'alignByWidthOnly'
,
'alignByHeightOnly'
,
'setParams'
,
'setMode'
],
obj
=
{};
$
.
each
(
methods
,
function
(
index
,
method
)
{
obj
[
method
]
=
jasmine
.
createSpy
(
method
).
andReturn
(
obj
);
});
return
obj
;
})();
}
function
initializeYouTube
()
{
...
...
@@ -557,6 +572,7 @@
it
(
'tell VideoCaption to resize'
,
function
()
{
expect
(
videoCaption
.
resize
).
toHaveBeenCalled
();
expect
(
state
.
resizer
.
setMode
).
toHaveBeenCalled
();
});
});
...
...
@@ -583,6 +599,7 @@
it
(
'tell VideoCaption to resize'
,
function
()
{
expect
(
videoCaption
.
resize
).
toHaveBeenCalled
();
expect
(
state
.
resizer
.
setMode
).
toHaveBeenCalledWith
(
'width'
);
});
});
});
...
...
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