forked from SoftwareBrothers/better-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.spec.js
62 lines (53 loc) · 1.78 KB
/
component.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const path = require('path')
const { expect } = require('chai')
const { parseVue, parseReact } = require('./component')
const VUE_PATH = path.join(__dirname, 'fixtures/component.vue')
const REACT_PATH = path.join(__dirname, 'fixtures/component.jsx')
describe('@component', function () {
describe('.parseVue', function () {
beforeEach(function () {
this.doclet = {}
this.output = parseVue(VUE_PATH, this.doclet)
})
it('returns displayName', function () {
expect(this.output.displayName).to.equal('grid')
})
it('returns prop types', function () {
expect(this.output.props).to.have.lengthOf(5)
expect(this.output.props[0]).to.deep.equal({
description: 'object/array defaults should be returned from a factory function',
name: 'msg',
required: true,
type: 'string|number',
defaultValue: 'function()'
})
expect(this.output.props[1]).to.have.property('defaultValue', '\'something\'')
})
it('returns slots', function () {
expect(this.output.slots).to.have.lengthOf(2)
expect(this.output.slots[0]).to.deep.equal({
name: 'header',
description: 'Use this slot header',
})
})
})
describe('.parseReact', function () {
beforeEach(function () {
this.doclet = {}
this.output = parseReact(REACT_PATH, this.doclet)
})
it('returns displayName', function () {
expect(this.output.displayName).to.equal('Documented')
})
it('returns prop types', function () {
expect(this.output.props).to.have.lengthOf(2)
expect(this.output.props[0]).to.deep.equal({
description: 'Text is a text',
name: 'text',
required: false,
type: 'string',
defaultValue: '\'Hello World\''
})
})
})
})