Skip to content

Commit 79275e7

Browse files
committed
Minor fixes
1 parent 2e63a81 commit 79275e7

File tree

4 files changed

+40
-91
lines changed

4 files changed

+40
-91
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
language: node_js
22
node_js:
3-
- 9
4-
- 10
5-
- 11
6-
- 12
7-
- 13
83
- 14
4+
- lts/*
95
- node
106
os:
117
- windows
128
- linux
139
- osx
10+
cache:
11+
directories:
12+
- node_modules
13+
script:
14+
- npm run test:unit
1415
# safelist
1516
branches:
1617
only:

src/components/Foo.vue

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/unit/example.spec.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/unit/vff-test.spec.js

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import FlowForm from '@/src/components/FlowForm.vue'
55
import FlowFormQuestion from '@/src/components/Question.vue'
66
import FlowFormMultipleChoiceType from '@/src/components/QuestionTypes/MultipleChoiceType.vue'
77

8-
const factory = (values = {}) => {
8+
9+
describe('Example', () => {
10+
11+
const factory = (values = {}) => {
912
return shallowMount(Example, {
1013
data () {
1114
return {
@@ -39,8 +42,6 @@ const wrapper = deepFactory({
3942
]
4043
})
4144

42-
describe('Example', () => {
43-
4445
let form
4546
let question
4647
let multipleChoice
@@ -53,26 +54,27 @@ describe('Example', () => {
5354
})()
5455

5556

56-
it('Example is a component', () => {
57+
it("is a component", () => {
5758

5859
const wrapper = factory()
5960

6061
expect(wrapper.findComponent(Example).vm)
6162
})
6263

63-
it('contains a FlowForm component', () => {
64+
it("contains a FlowForm component", () => {
6465

6566
const wrapper = factory()
6667

6768
expect(wrapper.findComponent(FlowForm).exists()).toBe(true)
6869
})
6970

7071

71-
it('renders a submit button on the final screen', () => {
72+
it("renders a submit button on the final screen", () => {
7273

7374
const wrapper = deepFactory()
74-
75-
expect(wrapper.find(".o-btn-action").text()).toBe("Submit")
75+
76+
expect(wrapper.find('.f-submit button').exists()).toBe(true)
77+
expect(wrapper.find('.f-submit button').text()).toBe("Submit")
7678
})
7779

7880

@@ -86,27 +88,45 @@ describe('Example', () => {
8688
setTimeout(() => {
8789
expect(form.find('.text-success').exists()).toBe(true)
8890
expect(form.classes('.f-submit')).toBe(false)
89-
}, 100)
91+
}, 10)
9092
})
9193

9294

93-
it("renders a MultipleChoice question type with one option", () => {
95+
it("renders one MultipleChoice type question", () => {
9496

9597
wrapper.vm.$nextTick(() => {
9698
expect(question.exists()).toBe(true)
9799
expect(form.findAllComponents(FlowFormQuestion)).toHaveLength(1)
98-
expect(question.find('.f-text').text()).toEqual("Question")
99-
expect(question.find('.f-enter').exists()).toBe(false)
100100
expect(multipleChoice.exists()).toBe(true)
101+
expect(multipleChoice.classes('.f-multiple')).toBe(false)
102+
})
103+
})
104+
105+
it("renders one option", () => {
106+
107+
wrapper.vm.$nextTick(() => {
101108
expect(multipleChoice.find('.f-radios').findAll('li')).toHaveLength(1)
109+
})
110+
})
111+
112+
it("renders question strings correctly", () => {
113+
114+
wrapper.vm.$nextTick(() => {
115+
expect(question.find('.f-text').text()).toEqual("Question")
102116
expect(multipleChoice.find('.f-key').exists()).toBe(true)
103117
expect(multipleChoice.find('.f-key').text()).toEqual("A")
104118
expect(multipleChoice.find('.f-label').exists()).toBe(true)
105119
expect(multipleChoice.find('.f-label').text()).toEqual("Answer")
106-
expect(multipleChoice.classes('.f-multiple')).toBe(false)
107-
expect(multipleChoice.classes('.f-selected')).toBe(false)
108120
})
121+
})
122+
123+
124+
it("doesn't render Enter button if not selected", () => {
109125

126+
wrapper.vm.$nextTick(() => {
127+
expect(multipleChoice.classes('.f-selected')).toBe(false)
128+
expect(question.find('.f-enter').exists()).toBe(false)
129+
})
110130
})
111131

112132
it("allows to select an answer and click OK", () => {
@@ -123,7 +143,6 @@ describe('Example', () => {
123143

124144
expect(question.emitted().answer).toBeTruthy()
125145
})
126-
127146
})
128147

129148
})

0 commit comments

Comments
 (0)