@@ -40,6 +40,7 @@ describe("bit-docs-html-codepen-link", function() {
40
40
html : {
41
41
dependencies : {
42
42
"bit-docs-html-codepen-link" : __dirname ,
43
+ "bit-docs-prettify" : "^0.4.0" ,
43
44
"bit-docs-tag-demo" : "^0.5.3"
44
45
}
45
46
} ,
@@ -54,10 +55,10 @@ describe("bit-docs-html-codepen-link", function() {
54
55
browser . window . CREATE_CODE_PEN = function ( data ) {
55
56
createCallData . push ( data ) ;
56
57
} ;
57
- var codePens = doc . querySelectorAll ( '.codepen ' ) ;
58
-
59
- Array . from ( codePens ) . forEach ( function ( codePen ) {
60
- codePen . click ( ) ;
58
+ var toolbars = doc . querySelectorAll ( '.toolbar ' ) ;
59
+ Array . from ( toolbars ) . forEach ( function ( toolbar ) {
60
+ var btn = toolbar . children [ toolbar . children . length - 1 ] . querySelector ( 'button' ) ;
61
+ btn . click ( ) ;
61
62
} ) ;
62
63
assert . deepEqual ( createCallData , [ {
63
64
html : '<my-app></my-app>' ,
@@ -70,8 +71,21 @@ describe("bit-docs-html-codepen-link", function() {
70
71
js : 'import {DefineMap} from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nconsole.log( myCounter.count ) //-> 1' ,
71
72
js_module : true ,
72
73
editors : '0011'
73
- }
74
- ] ) ;
74
+ } ,
75
+ {
76
+ css : 'h1 {color: red;}' ,
77
+ editors : '1011' ,
78
+ html : '<h1>Hi There!</h1>' ,
79
+ js : 'var code = "code";' ,
80
+ js_module : true
81
+ } ,
82
+ {
83
+ css : 'h1 {color: red;}' ,
84
+ editors : '1011' ,
85
+ html : '<h1>Hi There!</h1>' ,
86
+ js : 'var code = "code";' ,
87
+ js_module : true
88
+ } ] ) ;
75
89
76
90
close ( ) ;
77
91
done ( ) ;
@@ -223,4 +237,45 @@ describe("bit-docs-html-codepen-link", function() {
223
237
it ( "supports ts files" , function ( ) {
224
238
assert . ok ( codepenData . ts , "there is a ts" ) ;
225
239
} ) ;
240
+
241
+ it ( "Registers run code button" , function ( done ) {
242
+ this . timeout ( 60000 ) ;
243
+
244
+ var docMap = Promise . resolve ( {
245
+ index : {
246
+ name : "index" ,
247
+ demo : "path/to/demo.html" ,
248
+ body : fs . readFileSync ( __dirname + "/test-demo.md" , "utf8" ) ,
249
+ codepen : [
250
+ [ "can" , "//unpkg.com/can@^5.0.0-pre.1/core.mjs" ]
251
+ ]
252
+ }
253
+ } ) ;
254
+
255
+ generate ( docMap , {
256
+ html : {
257
+ dependencies : {
258
+ "bit-docs-html-codepen-link" : __dirname ,
259
+ "bit-docs-prettify" : "^0.4.0" ,
260
+ "bit-docs-tag-demo" : "^0.5.3"
261
+ }
262
+ } ,
263
+ dest : path . join ( __dirname , "temp" ) ,
264
+ parent : "index" ,
265
+ forceBuild : true ,
266
+ minifyBuild : false
267
+ } ) . then ( function ( ) {
268
+ open ( "temp/index.html" , function ( browser , close ) {
269
+ var doc = browser . window . document ;
270
+ var toolbars = doc . querySelectorAll ( ".code-toolbar" ) ;
271
+ toolbars . forEach ( function ( toolbar ) {
272
+ var children = toolbar . children ;
273
+ assert . equal ( toolbar . children . length , 2 ) ;
274
+ assert . equal ( children [ children . length - 1 ] . innerHTML , '<div class="toolbar-item"><button>Copy</button></div><div class="toolbar-item"><button>Run</button></div>' ) ;
275
+ } ) ;
276
+ close ( ) ;
277
+ done ( ) ;
278
+ } , done ) ;
279
+ } , done ) ;
280
+ } ) ;
226
281
} ) ;
0 commit comments