diff --git a/cms/static/cms/js/spec/main.js b/cms/static/cms/js/spec/main.js index 4e093ee573b4..46a20ac51708 100644 --- a/cms/static/cms/js/spec/main.js +++ b/cms/static/cms/js/spec/main.js @@ -243,6 +243,7 @@ 'js/spec/video/transcripts/message_manager_spec', 'js/spec/video/transcripts/utils_spec', 'js/spec/video/transcripts/editor_spec', + 'js/spec/video/transcripts/videolist_spec', 'js/spec/video/transcripts/file_uploader_spec', 'js/spec/models/component_template_spec', 'js/spec/models/explicit_url_spec', diff --git a/cms/static/js/spec/video/transcripts/videolist_spec.js b/cms/static/js/spec/video/transcripts/videolist_spec.js new file mode 100644 index 000000000000..908d519d8921 --- /dev/null +++ b/cms/static/js/spec/video/transcripts/videolist_spec.js @@ -0,0 +1,788 @@ +define( + [ + 'jquery', 'underscore', 'backbone', + 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', + 'js/views/video/transcripts/utils', + 'js/views/video/transcripts/editor', + 'js/views/video/transcripts/metadata_videolist', 'js/models/metadata', + 'js/views/abstract_editor', + 'js/views/video/transcripts/message_manager', + 'xmodule' + ], + function($, _, Backbone, AjaxHelpers, Utils, Editor, VideoList, MetadataModel, AbstractEditor, MessageManager) { + 'use strict'; + + describe('CMS.Views.Metadata.VideoList', function() { + var videoListEntryTemplate = readFixtures( + 'video/transcripts/metadata-videolist-entry.underscore' + ), + abstractEditor = AbstractEditor.prototype, + component_locator = 'component_locator', + videoList = [ + { + mode: 'youtube', + type: 'youtube', + video: '12345678901' + }, + { + mode: 'html5', + type: 'mp4', + video: 'video' + }, + { + mode: 'html5', + type: 'webm', + video: 'video' + } + ], + modelStub = { + default_value: ['a thing', 'another thing'], + display_name: 'Video URL', + explicitly_set: true, + field_name: 'video_url', + help: 'A list of things.', + options: [], + type: MetadataModel.VIDEO_LIST_TYPE, + value: [ + 'http://youtu.be/12345678901', + 'video.mp4', + 'video.webm' + ] + }, + videoIDStub = { + default_value: 'test default value', + display_name: 'Video ID', + explicitly_set: true, + field_name: 'edx_video_id', + help: 'Specifies the video ID.', + options: [], + type: 'VideoID', + value: 'advanced tab video id' + }, + response = JSON.stringify({ + command: 'found', + status: 'Success', + subs: 'video_id' + }), + waitForEvent, + createVideoListView; + + var createMockAjaxServer = function() { + var mockServer = AjaxHelpers.server( + [ + 200, + {'Content-Type': 'application/json'}, + response + ] + ); + mockServer.autoRespond = true; + return mockServer; + }; + + beforeEach(function() { + var tpl = sandbox({ // eslint-disable-line no-undef + class: 'component', + 'data-locator': component_locator + }); + + setFixtures(tpl); + + appendSetFixtures( + $('