Skip to content

Commit 17aff18

Browse files
committed
began writing tests
1 parent 3ed7a45 commit 17aff18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+112
-96
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
// cache: false,
1111
// verbose: true,
1212
// watch: true,
13-
collectCoverage: true,
13+
collectCoverage: false,
1414
coverageDirectory: '<rootDir>/test/jest/coverage',
1515
collectCoverageFrom: [
1616
'<rootDir>/src/**/*.vue',

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/store/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const actions = {
122122
[types.deleteComponent]: ({state, commit }, payload) => {
123123
console.log('payload in actions:', payload)
124124
commit(types.DELETE_COMPONENT, payload)
125-
}
125+
},
126126
}
127127

128128
export default actions

test/jest/__tests__/App.spec.js

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,85 @@
22
/**
33
* @jest-environment jsdom
44
*/
5-
5+
import actions from '../../store/actions';
66
import { mount, createLocalVue, shallowMount } from '@vue/test-utils'
77
import QBUTTON from './demo/QBtn-demo.vue'
88
import * as All from 'quasar'
99
// import langEn from 'quasar/lang/en-us' // change to any language you wish! => this breaks wallaby :(
1010
const { Quasar, date } = All
1111

12+
const localVue = createLocalVue()
13+
14+
localVue.use(Vuex)
15+
1216
const components = Object.keys(All).reduce((object, key) => {
1317
const val = All[key]
1418
if (val && val.component && val.component.name != null) {
1519
object[key] = val
1620
}
1721
return object
1822
}, {})
19-
20-
describe('Dummy test', () => {
23+
/*
24+
describe('Mount Quasar', () => {
2125
const localVue = createLocalVue()
22-
localVue.use(Quasar, { components })
23-
const testValue = false;
24-
it('does this produce the correct result', () => {
25-
expect(testValue).toBe(false)
26+
localVue.use(Quasar, { components }) // , lang: langEn
27+
28+
const wrapper = mount(QBUTTON, {
29+
localVue
30+
})
31+
const vm = wrapper.vm
32+
33+
it('passes the sanity check and creates a wrapper', () => {
34+
expect(wrapper.isVueInstance()).toBe(true)
2635
})
27-
})
2836
29-
// describe('Mount Quasar', () => {
30-
// const localVue = createLocalVue()
31-
// localVue.use(Quasar, { components }) // , lang: langEn
37+
it('has a created hook', () => {
38+
expect(typeof vm.increment).toBe('function')
39+
})
3240
33-
// const wrapper = mount(QBUTTON, {
34-
// localVue
35-
// })
36-
// const vm = wrapper.vm
41+
it('accesses the shallowMount', () => {
42+
expect(vm.$el.textContent).toContain('rocket muffin')
43+
expect(wrapper.text()).toContain('rocket muffin') // easier
44+
expect(wrapper.find('p').text()).toContain('rocket muffin')
45+
})
3746
38-
// it('passes the sanity check and creates a wrapper', () => {
39-
// expect(wrapper.isVueInstance()).toBe(true)
40-
// })
47+
it('sets the correct default data', () => {
48+
expect(typeof vm.counter).toBe('number')
49+
const defaultData2 = QBUTTON.data()
50+
expect(defaultData2.counter).toBe(0)
51+
})
4152
42-
// it('has a created hook', () => {
43-
// expect(typeof vm.increment).toBe('function')
44-
// })
53+
it('correctly updates data when button is pressed', () => {
54+
const button = wrapper.find('button')
55+
button.trigger('click')
56+
expect(vm.counter).toBe(1)
57+
})
4558
46-
// it('accesses the shallowMount', () => {
47-
// expect(vm.$el.textContent).toContain('rocket muffin')
48-
// expect(wrapper.text()).toContain('rocket muffin') // easier
49-
// expect(wrapper.find('p').text()).toContain('rocket muffin')
50-
// })
59+
it('formats a date without throwing exception', () => {
60+
// test will automatically fail if an exception is thrown
61+
// MMMM and MMM require that a language is 'installed' in Quasar
62+
let formattedString = date.formatDate(Date.now(), 'YYYY MMMM MMM DD')
63+
console.log('formattedString', formattedString)
64+
})
65+
})
66+
*/
67+
describe('actions', () => {
68+
let userActions;
69+
let userStore;
5170

52-
// it('sets the correct default data', () => {
53-
// expect(typeof vm.counter).toBe('number')
54-
// const defaultData2 = QBUTTON.data()
55-
// expect(defaultData2.counter).toBe(0)
56-
// })
71+
beforeEach(() => {
72+
actions = {
73+
userActionInput: jest.fn(),
74+
userStore: jest.fn()
75+
}
76+
store = new Vuex.Store({
77+
actions
78+
})
79+
})
5780

58-
// it('correctly updates data when button is pressed', () => {
59-
// const button = wrapper.find('button')
60-
// button.trigger('click')
61-
// expect(vm.counter).toBe(1)
62-
// })
81+
it('should take in a string and output a string into userActions array', () => {
82+
const wrapper = shallowMount(actions, {store, localVue })
83+
84+
})
6385

64-
// it('formats a date without throwing exception', () => {
65-
// // test will automatically fail if an exception is thrown
66-
// // MMMM and MMM require that a language is 'installed' in Quasar
67-
// let formattedString = date.formatDate(Date.now(), 'YYYY MMMM MMM DD')
68-
// console.log('formattedString', formattedString)
69-
// })
70-
// })
86+
});

test/jest/coverage/clover.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<coverage generated="1563215612795" clover="3.2.0">
3-
<project timestamp="1563215612795" name="All files">
2+
<coverage generated="1563225499366" clover="3.2.0">
3+
<project timestamp="1563225499366" name="All files">
44
<metrics statements="413" coveredstatements="0" conditionals="52" coveredconditionals="0" methods="155" coveredmethods="0" elements="620" coveredelements="0" complexity="0" loc="413" ncloc="413" packages="10" files="34" classes="34"/>
55
<package name="src-electron.main-process">
66
<metrics statements="19" coveredstatements="0" conditionals="6" coveredconditionals="0" methods="7" coveredmethods="0"/>

test/jest/coverage/lcov-report/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ <h1>
197197
</div><!-- /wrapper -->
198198
<div class='footer quiet pad2 space-top1 center small'>
199199
Code coverage
200-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 11:33:32 GMT-0700 (Pacific Daylight Time)
200+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 14:18:19 GMT-0700 (Pacific Daylight Time)
201201
</div>
202202
</div>
203203
<script src="prettify.js"></script>

test/jest/coverage/lcov-report/src-electron/main-process/electron-main.dev.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ <h1>
118118
</div><!-- /wrapper -->
119119
<div class='footer quiet pad2 space-top1 center small'>
120120
Code coverage
121-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 11:33:32 GMT-0700 (Pacific Daylight Time)
121+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 14:18:19 GMT-0700 (Pacific Daylight Time)
122122
</div>
123123
</div>
124124
<script src="../../prettify.js"></script>

test/jest/coverage/lcov-report/src-electron/main-process/electron-main.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ <h1>
187187
</div><!-- /wrapper -->
188188
<div class='footer quiet pad2 space-top1 center small'>
189189
Code coverage
190-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 11:33:32 GMT-0700 (Pacific Daylight Time)
190+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 14:18:19 GMT-0700 (Pacific Daylight Time)
191191
</div>
192192
</div>
193193
<script src="../../prettify.js"></script>

test/jest/coverage/lcov-report/src-electron/main-process/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ <h1>
9393
</div><!-- /wrapper -->
9494
<div class='footer quiet pad2 space-top1 center small'>
9595
Code coverage
96-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 11:33:32 GMT-0700 (Pacific Daylight Time)
96+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 14:18:19 GMT-0700 (Pacific Daylight Time)
9797
</div>
9898
</div>
9999
<script src="../../prettify.js"></script>

test/jest/coverage/lcov-report/src-pwa/custom-service-worker.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h1>
6767
</div><!-- /wrapper -->
6868
<div class='footer quiet pad2 space-top1 center small'>
6969
Code coverage
70-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 11:33:32 GMT-0700 (Pacific Daylight Time)
70+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jul 15 2019 14:18:19 GMT-0700 (Pacific Daylight Time)
7171
</div>
7272
</div>
7373
<script src="../prettify.js"></script>

0 commit comments

Comments
 (0)