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 1
1
language : node_js
2
2
node_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
8
4
branches :
9
- except :
10
- - /^v\d+\.\d+\.\d+$/
5
+ only :
6
+ - master
11
7
script :
12
8
- npm run test
13
9
stages :
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import parseModule from './parseModule'
7
7
module . exports = function getSandbox ( stateDoc , file ) {
8
8
const parsedSource = parseModule ( stateDoc . jscodeRequest , file , stateDoc . jscodeLang )
9
9
const sandbox = evalComponentCode ( parsedSource ) . exports
10
+ sandbox . default = sandbox . default || { }
10
11
const component = sandbox . default
11
12
const listRequire = getSourceInRequire ( parsedSource , file )
12
13
const mixins = getMixin ( listRequire ) . reverse ( )
Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ class stateDoc {
23
23
if ( this . isMainComponent ( file ) && this . sourceComponent !== source ) {
24
24
const parts = parser ( source , 'name' )
25
25
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
+ }
29
32
}
30
33
}
31
34
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