This repository was archived by the owner on Mar 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +59
-10
lines changed
tests/components/button-noscript Expand file tree Collapse file tree 5 files changed +59
-10
lines changed Original file line number Diff line number Diff line change 11language : node_js
22node_js :
3- - 9
4- install :
5- # Use npm 5.7.x since it has introduced `npm ci`
6- - if [[ `npm -v` != 5.7* ]]; then npm install -g npm@'>=5.7.1'; fi
7- - npm ci
3+ - 10
84branches :
9- except :
10- - /^v\d+\.\d+\.\d+$/
5+ only :
6+ - master
117script :
128 - npm run test
139stages :
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import parseModule from './parseModule'
77module . exports = function getSandbox ( stateDoc , file ) {
88 const parsedSource = parseModule ( stateDoc . jscodeRequest , file , stateDoc . jscodeLang )
99 const sandbox = evalComponentCode ( parsedSource ) . exports
10+ sandbox . default = sandbox . default || { }
1011 const component = sandbox . default
1112 const listRequire = getSourceInRequire ( parsedSource , file )
1213 const mixins = getMixin ( listRequire ) . reverse ( )
Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ class stateDoc {
2323 if ( this . isMainComponent ( file ) && this . sourceComponent !== source ) {
2424 const parts = parser ( source , 'name' )
2525 this . slots = getSlots ( parts )
26- this . jscodeRequest = getComponentModuleJSCode ( parts , source , file )
27- this . jscodeLang = parts . script . lang
28- this . docComponent = this . getDocFile ( this . jscodeRequest , file , this . jscodeLang )
26+ this . docComponent = [ ]
27+ if ( parts . script ) {
28+ this . jscodeRequest = getComponentModuleJSCode ( parts , source , file )
29+ this . jscodeLang = parts . script . lang
30+ this . docComponent = this . getDocFile ( this . jscodeRequest , file , this . jscodeLang )
31+ }
2932 }
3033 }
3134
Original file line number Diff line number Diff line change 1+ <template >
2+ <button class =" buttonComponent" >
3+ <!-- @slot Use this slot default -->
4+ <slot />
5+ </button >
6+ </template >
7+
8+ <style scoped>
9+ .button {
10+ padding : 0.5em 1.5em ;
11+ color : #666 ;
12+ background-color : #fff ;
13+ border : 1px solid blue ;
14+ border-radius : 0.3em ;
15+ text-align : center ;
16+ vertical-align : middle ;
17+ cursor : pointer ;
18+ }
19+ </style >
Original file line number Diff line number Diff line change 1+ const path = require ( 'path' )
2+ const expect = require ( 'chai' ) . expect
3+
4+ const api = require ( '../../../dist/main' )
5+ const button = path . join ( __dirname , './MyButton.vue' )
6+ let docButton
7+
8+ describe . only ( 'tests button' , ( ) => {
9+ before ( function ( done ) {
10+ this . timeout ( 10000 )
11+ docButton = api . parse ( button )
12+ done ( )
13+ } )
14+
15+ it ( 'should return an object' , ( ) => {
16+ expect ( docButton ) . to . be . an ( 'object' )
17+ } )
18+
19+ it ( 'should have a slot.' , ( ) => {
20+ expect ( Object . keys ( docButton [ 'slots' ] ) . length ) . to . equal ( 1 )
21+ } )
22+
23+ it ( 'should have a default slot.' , ( ) => {
24+ expect ( typeof docButton [ 'slots' ] [ 'default' ] !== 'undefined' ) . to . be . true
25+ } )
26+
27+ it ( 'the default slot should have "Use this slot default" as description' , ( ) => {
28+ expect ( docButton [ 'slots' ] [ 'default' ] [ 'description' ] ) . to . equal ( 'Use this slot default' )
29+ } )
30+ } )
You can’t perform that action at this time.
0 commit comments