Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

Commit beba3b0

Browse files
authored
tests(e2e): make the tests a little more literal (#74)
here I fix a few mistakes that were made in the writing of e2e tests this will help us monitor the refactoring of the library some of the components were not valid vue components some of the texts were not understandable english * run prettier on unit tests files * fix failing snapshot
1 parent 4e9cd8d commit beba3b0

File tree

21 files changed

+487
-478
lines changed

21 files changed

+487
-478
lines changed
Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,9 @@
11
<template functional>
2-
<button :style="`width: ${size}px;`" class="buttonComponent">
3-
<!-- @slot Use this slot default -->
4-
<slot/>
5-
</button>
2+
<div>
3+
<button :style="`width: ${props.size}px;`" class="buttonComponent">
4+
<!-- @slot Use this slot default -->
5+
<slot/>
6+
</button>
7+
{{props.text}}
8+
</div>
69
</template>
7-
8-
<script>
9-
export default {
10-
functional: true,
11-
props: {
12-
/**
13-
* The size of the button
14-
*/
15-
size: {
16-
default: 'normal',
17-
},
18-
},
19-
}
20-
</script>
21-
22-
<style scoped>
23-
.button {
24-
padding: 0.5em 1.5em;
25-
color: #666;
26-
background-color: #fff;
27-
border: 1px solid blue;
28-
border-radius: 0.3em;
29-
text-align: center;
30-
vertical-align: middle;
31-
cursor: pointer;
32-
}
33-
</style>

tests/components/button-functinoal/__snapshots__/button-functional.test.js.snap

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`tests button should match the snapshot 1`] = `
3+
exports[`tests button functional should match the snapshot 1`] = `
44
Object {
55
"comment": "",
66
"description": "",
77
"displayName": "MyButton",
88
"events": Object {},
99
"methods": Array [],
10-
"props": Object {
11-
"size": Object {
12-
"comment": "/**
13-
* The size of the button
14-
*/",
15-
"defaultValue": Object {
16-
"func": false,
17-
"value": "\\"normal\\"",
18-
},
19-
"description": "The size of the button",
20-
"required": "",
21-
"tags": Object {},
22-
"type": Object {
23-
"name": "string",
24-
},
25-
},
26-
},
10+
"props": undefined,
2711
"slots": Object {
2812
"default": Object {
2913
"description": "Use this slot default",

tests/components/button-functinoal/button-functional.test.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
const path = require('path')
1+
import * as path from 'path'
22

3-
const api = require('../../../src/main')
3+
import { parse } from '../../../src/main'
44
const button = path.join(__dirname, './MyButton.vue')
55
let docButton
66

7-
describe('tests button', () => {
8-
beforeEach(function(done) {
9-
docButton = api.parse(button)
7+
describe('tests button functional', () => {
8+
beforeEach(done => {
9+
docButton = parse(button)
1010
done()
1111
})
1212

1313
it('should have a slot.', () => {
14-
expect(Object.keys(docButton['slots']).length).toEqual(1)
14+
expect(Object.keys(docButton.slots).length).toEqual(1)
1515
})
1616

1717
it('should have a default slot.', () => {
18-
expect(typeof docButton['slots']['default'] !== 'undefined').toBe(true)
18+
expect(docButton.slots.default).not.toBeUndefined()
1919
})
2020

2121
it('the default slot should have "Use this slot default" as description', () => {
22-
expect(docButton['slots']['default']['description']).toEqual('Use this slot default')
22+
expect(docButton.slots.default.description).toEqual('Use this slot default')
2323
})
2424

25-
it('should the component has size prop description equal The size of the button', () => {
26-
expect(docButton['props']['size']['description']).toEqual('The size of the button')
27-
})
28-
2925
it('should match the snapshot', () => {
3026
expect(docButton).toMatchSnapshot()
3127
})

tests/components/button-noscript/__snapshots__/button-noscript.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`tests button should match the snapshot 1`] = `
3+
exports[`tests button with no script block should match the snapshot 1`] = `
44
Object {
55
"comment": "",
66
"description": "",

tests/components/button-noscript/button-noscript.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const path = require('path')
1+
import * as path from 'path'
22

3-
const api = require('../../../src/main')
3+
import { parse } from '../../../src/main'
44
const button = path.join(__dirname, './MyButton.vue')
55
let docButton
66

7-
describe('tests button', () => {
8-
beforeEach(function(done) {
9-
docButton = api.parse(button)
7+
describe('tests button with no script block', () => {
8+
beforeEach(done => {
9+
docButton = parse(button)
1010
done()
1111
})
1212

1313
it('should have a slot.', () => {
14-
expect(Object.keys(docButton['slots']).length).toEqual(1)
14+
expect(Object.keys(docButton.slots).length).toEqual(1)
1515
})
1616

1717
it('should have a default slot.', () => {
18-
expect(typeof docButton['slots']['default'] !== 'undefined').toBe(true)
18+
expect(typeof docButton.slots.default !== 'undefined').toBe(true)
1919
})
2020

2121
it('the default slot should have "Use this slot default" as description', () => {
22-
expect(docButton['slots']['default']['description']).toEqual('Use this slot default')
22+
expect(docButton.slots.default.description).toEqual('Use this slot default')
2323
})
2424

2525
it('should match the snapshot', () => {

tests/components/button-typescript/Button.vue

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
<template>
2-
<button class="buttonComponent" @click.prevent="onClick">
3-
<!-- @slot Use this slot default -->
4-
<slot></slot>
5-
</button>
2+
<button class="buttonComponent" @click.prevent="onClick">
3+
<!-- @slot Use this slot default -->
4+
<slot></slot>
5+
</button>
66
</template>
77

88
<script lang='ts'>
9-
import {
10-
Component,
11-
Emit,
12-
Inject,
13-
Model,
14-
Prop,
15-
Provide,
16-
Vue,
17-
Watch,
18-
} from 'vue-property-decorator'
19-
import anotherMixin from '../../mixins/anotherMixin'
20-
import genericMixin from './genericMixin'
21-
import colorMixin from './colorMixin'
9+
import { Component, Prop, Vue } from 'vue-property-decorator'
2210
2311
/**
2412
* This is an example of creating a reusable button component and using it with external data.
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
const path = require('path')
1+
import * as path from 'path'
22

3-
const api = require('../../../src/main')
3+
import { parse } from '../../../src/main'
44
const button = path.join(__dirname, './Button.vue')
55

66
let docButton
77
xdescribe('tests button', () => {
8-
beforeAll(function(done) {
9-
docButton = api.parse(button)
10-
done()
11-
})
12-
13-
it('should return an object', () => {
14-
expect(typeof docButton).toEqual('object')
15-
})
16-
});
8+
beforeAll(done => {
9+
docButton = parse(button)
10+
done()
11+
})
12+
13+
it('should return an object', () => {
14+
expect(typeof docButton).toEqual('object')
15+
})
16+
})

tests/components/button/button.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const path = require('path')
1+
import * as path from 'path'
22

3-
const api = require('../../../src/main')
3+
import { parse } from '../../../src/main'
44
const button = path.join(__dirname, './Button.vue')
55
let docButton
66

77
describe('tests button', () => {
8-
beforeAll(function(done) {
9-
docButton = api.parse(button)
8+
beforeAll(done => {
9+
docButton = parse(button)
1010
done()
1111
})
1212

tests/components/extended/Base.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const path = require('path')
1+
import * as path from 'path'
22

3-
const api = require('../../../src/main')
3+
import { parse } from '../../../src/main'
44
const Base = path.join(__dirname, './Base.vue')
55
let docBase
66

77
describe('tests Base', () => {
8-
beforeAll(function(done) {
9-
docBase = api.parse(Base)
8+
beforeAll(done => {
9+
docBase = parse(Base)
1010
done()
1111
})
1212

@@ -23,10 +23,10 @@ describe('tests Base', () => {
2323
})
2424

2525
it('should has props', () => {
26-
expect(typeof docBase['props'] !== 'undefined').toBe(true)
26+
expect(typeof docBase.props !== 'undefined').toBe(true)
2727
})
2828

2929
it('should the component has one prop', () => {
30-
expect(Object.keys(docBase['props']).length).toEqual(1)
30+
expect(Object.keys(docBase.props || {}).length).toEqual(1)
3131
})
3232
})

tests/components/extended/InputText.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
const path = require('path')
2-
3-
const api = require('../../../src/main')
1+
import * as path from 'path'
2+
import { parse } from '../../../src/main'
43
const InputText = path.join(__dirname, './InputText.vue')
54
let docInputText
65

76
describe('tests InputText', () => {
8-
beforeAll(function(done) {
9-
docInputText = api.parse(InputText)
7+
beforeAll(done => {
8+
docInputText = parse(InputText)
109
done()
1110
})
1211

@@ -23,11 +22,11 @@ describe('tests InputText', () => {
2322
})
2423

2524
it('should has props', () => {
26-
expect(docInputText['props']).not.toBeUndefined()
25+
expect(docInputText.props).not.toBeUndefined()
2726
})
2827

2928
it('should the component has two props', () => {
30-
expect(Object.keys(docInputText['props']).length).toEqual(2)
29+
expect(Object.keys(docInputText.props || {}).length).toEqual(2)
3130
})
3231

3332
it('should match the snapshot', () => {

0 commit comments

Comments
 (0)