diff --git a/common/lib/xmodule/xmodule/js/spec/video/resizer_spec.js b/common/lib/xmodule/xmodule/js/spec/video/resizer_spec.js
new file mode 100644
index 0000000000..501f844ffd
--- /dev/null
+++ b/common/lib/xmodule/xmodule/js/spec/video/resizer_spec.js
@@ -0,0 +1,94 @@
+(function (requirejs, require, define) {
+
+require(
+['video/00_resizer.js'],
+function (Resizer) {
+
+ describe('Resizer', function () {
+ var config, container, element;
+
+ beforeEach(function () {
+ var html = [
+ '
',
+ '
',
+ 'Content',
+ '
',
+ '
'
+ ].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));
diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
index 00f51a4c80..3f5e1831ac 100644
--- a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
+++ b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
@@ -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');
});
});
});