webapp.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Created with JetBrains PhpStorm.
  3. * User: taoqili
  4. * Date: 12-6-5
  5. * Time: 下午2:52
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. module( 'plugins.webapp' );
  9. test("插入一个webapp",function(){
  10. stop();
  11. expect(7);
  12. var editor = te.obj[0];
  13. equal(editor.options.initialContent,editor.getContent(),"没插入webapp之前内容为空");
  14. editor.execCommand( "webapp", {
  15. url:"http://app.baidu.com/app/enter?appid=152311&tn=app_canvas&app_spce_id=1&apikey=5r7SmiUici27lVfVBep1K7BA&api_key=5r7SmiUici27lVfVBep1K7BA",
  16. width:300,
  17. height:400,
  18. logo:'http://apps1.bdimg.com/store/static/kvt/2c86377ca162d93547aeeca6fe252696.jpgo',
  19. title:'测试'
  20. });
  21. var backImg = editor.document.getElementsByTagName("img")[0];
  22. var div = document.createElement("div");
  23. div.innerHTML = editor.getContent();
  24. var iframe = div.getElementsByTagName("iframe")[0];
  25. ok(iframe,"插入webapp后获取到的内容中包含一个iframe");
  26. if(iframe){
  27. equal(iframe.className,"edui-faked-webapp","获取到的iframe中包含edui-faked-webapp类名");
  28. ok(iframe.getAttribute("logo_url"),"包含一个logo_url属性");
  29. }
  30. setTimeout( function () {
  31. editor.execCommand( 'source' );
  32. setTimeout( function () {
  33. editor.execCommand( 'source' );
  34. var newImg = editor.document.getElementsByTagName("img")[0];
  35. ok(newImg.src ==backImg.src,"源码切换之后占位图片地址不变");
  36. ok(newImg.className ==backImg.className,"源码切换之后占位图片样式类不变");
  37. ok(newImg._url ==backImg._url,"源码切换之后占位图片_url数据不变");
  38. start();
  39. }, 200 );
  40. }, 200 );
  41. });