VideoDialog.spec.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * VideoDialog.spec.js
  3. * (c) 2015~ Summernote Team
  4. * summernote may be freely distributed under the MIT license./
  5. */
  6. import chai from 'chai';
  7. import $ from 'jquery';
  8. import Context from '../../../../src/js/base/Context';
  9. import VideoDialog from '../../../../src/js/base/module/VideoDialog';
  10. var expect = chai.expect;
  11. describe('bs:module.VideoDialog', () => {
  12. function expectUrl(source, target) {
  13. var iframe = $video.createVideoNode(source);
  14. expect(iframe).to.not.equal(false);
  15. expect(iframe.tagName).to.equal('IFRAME');
  16. expect(iframe.src).to.equal(target);
  17. }
  18. var context, $video;
  19. beforeEach(() => {
  20. var $note = $('<div></div>').appendTo('body');
  21. var options = $.extend({}, $.summernote.options);
  22. options.langInfo = $.extend(true, {}, $.summernote.lang['en-US'], $.summernote.lang[options.lang]);
  23. options.toolbar = [
  24. ['video', ['video']]
  25. ];
  26. context = new Context($note, options);
  27. context.initialize();
  28. $video = new VideoDialog(context);
  29. });
  30. describe('#createVideoNode', () => {
  31. it('should execute when insert other url', () => {
  32. expect($video.createVideoNode('http://www.google.com')).to.equal(false);
  33. expect($video.createVideoNode('http://www.youtube.com')).to.equal(false);
  34. expect($video.createVideoNode('http://www.facebook.com')).to.equal(false);
  35. });
  36. it('should execute when insert v.qq.com', () => {
  37. expectUrl('http://v.qq.com/cover/6/640ewqy2v071ppd.html?vid=f0196y2b2cx',
  38. 'http://v.qq.com/iframe/player.html?vid=f0196y2b2cx&amp;auto=0');
  39. expectUrl('http://v.qq.com/x/page/p0330y279lm.html',
  40. 'http://v.qq.com/iframe/player.html?vid=p0330y279lm&amp;auto=0');
  41. });
  42. });
  43. });