Skip to content

Commit

Permalink
began writing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deanfchung committed Jul 15, 2019
1 parent 3ed7a45 commit 17aff18
Show file tree
Hide file tree
Showing 50 changed files with 112 additions and 96 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Expand Up @@ -10,7 +10,7 @@ module.exports = {
// cache: false,
// verbose: true,
// watch: true,
collectCoverage: true,
collectCoverage: false,
coverageDirectory: '<rootDir>/test/jest/coverage',
collectCoverageFrom: [
'<rootDir>/src/**/*.vue',
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/store/actions.js
Expand Up @@ -122,7 +122,7 @@ const actions = {
[types.deleteComponent]: ({state, commit }, payload) => {
console.log('payload in actions:', payload)
commit(types.DELETE_COMPONENT, payload)
}
},
}

export default actions
102 changes: 59 additions & 43 deletions test/jest/__tests__/App.spec.js
Expand Up @@ -2,69 +2,85 @@
/**
* @jest-environment jsdom
*/

import actions from '../../store/actions';
import { mount, createLocalVue, shallowMount } from '@vue/test-utils'
import QBUTTON from './demo/QBtn-demo.vue'
import * as All from 'quasar'
// import langEn from 'quasar/lang/en-us' // change to any language you wish! => this breaks wallaby :(
const { Quasar, date } = All

const localVue = createLocalVue()

localVue.use(Vuex)

const components = Object.keys(All).reduce((object, key) => {
const val = All[key]
if (val && val.component && val.component.name != null) {
object[key] = val
}
return object
}, {})

describe('Dummy test', () => {
/*
describe('Mount Quasar', () => {
const localVue = createLocalVue()
localVue.use(Quasar, { components })
const testValue = false;
it('does this produce the correct result', () => {
expect(testValue).toBe(false)
localVue.use(Quasar, { components }) // , lang: langEn
const wrapper = mount(QBUTTON, {
localVue
})
const vm = wrapper.vm
it('passes the sanity check and creates a wrapper', () => {
expect(wrapper.isVueInstance()).toBe(true)
})
})
// describe('Mount Quasar', () => {
// const localVue = createLocalVue()
// localVue.use(Quasar, { components }) // , lang: langEn
it('has a created hook', () => {
expect(typeof vm.increment).toBe('function')
})
// const wrapper = mount(QBUTTON, {
// localVue
// })
// const vm = wrapper.vm
it('accesses the shallowMount', () => {
expect(vm.$el.textContent).toContain('rocket muffin')
expect(wrapper.text()).toContain('rocket muffin') // easier
expect(wrapper.find('p').text()).toContain('rocket muffin')
})
// it('passes the sanity check and creates a wrapper', () => {
// expect(wrapper.isVueInstance()).toBe(true)
// })
it('sets the correct default data', () => {
expect(typeof vm.counter).toBe('number')
const defaultData2 = QBUTTON.data()
expect(defaultData2.counter).toBe(0)
})
// it('has a created hook', () => {
// expect(typeof vm.increment).toBe('function')
// })
it('correctly updates data when button is pressed', () => {
const button = wrapper.find('button')
button.trigger('click')
expect(vm.counter).toBe(1)
})
// it('accesses the shallowMount', () => {
// expect(vm.$el.textContent).toContain('rocket muffin')
// expect(wrapper.text()).toContain('rocket muffin') // easier
// expect(wrapper.find('p').text()).toContain('rocket muffin')
// })
it('formats a date without throwing exception', () => {
// test will automatically fail if an exception is thrown
// MMMM and MMM require that a language is 'installed' in Quasar
let formattedString = date.formatDate(Date.now(), 'YYYY MMMM MMM DD')
console.log('formattedString', formattedString)
})
})
*/
describe('actions', () => {
let userActions;
let userStore;

// it('sets the correct default data', () => {
// expect(typeof vm.counter).toBe('number')
// const defaultData2 = QBUTTON.data()
// expect(defaultData2.counter).toBe(0)
// })
beforeEach(() => {
actions = {
userActionInput: jest.fn(),
userStore: jest.fn()
}
store = new Vuex.Store({
actions
})
})

// it('correctly updates data when button is pressed', () => {
// const button = wrapper.find('button')
// button.trigger('click')
// expect(vm.counter).toBe(1)
// })
it('should take in a string and output a string into userActions array', () => {
const wrapper = shallowMount(actions, {store, localVue })

})

// it('formats a date without throwing exception', () => {
// // test will automatically fail if an exception is thrown
// // MMMM and MMM require that a language is 'installed' in Quasar
// let formattedString = date.formatDate(Date.now(), 'YYYY MMMM MMM DD')
// console.log('formattedString', formattedString)
// })
// })
});
4 changes: 2 additions & 2 deletions test/jest/coverage/clover.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1563215612795" clover="3.2.0">
<project timestamp="1563215612795" name="All files">
<coverage generated="1563225499366" clover="3.2.0">
<project timestamp="1563225499366" name="All files">
<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"/>
<package name="src-electron.main-process">
<metrics statements="19" coveredstatements="0" conditionals="6" coveredconditionals="0" methods="7" coveredmethods="0"/>
Expand Down
2 changes: 1 addition & 1 deletion test/jest/coverage/lcov-report/index.html
Expand Up @@ -197,7 +197,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
Expand Up @@ -118,7 +118,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -187,7 +187,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -93,7 +93,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -67,7 +67,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/jest/coverage/lcov-report/src-pwa/index.html
Expand Up @@ -93,7 +93,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
Expand Up @@ -175,7 +175,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
Expand Up @@ -274,7 +274,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -445,7 +445,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -754,7 +754,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -349,7 +349,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -277,7 +277,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -469,7 +469,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -304,7 +304,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -238,7 +238,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -313,7 +313,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Expand Up @@ -80,7 +80,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Expand Up @@ -238,7 +238,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -232,7 +232,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -247,7 +247,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -196,7 +196,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -343,7 +343,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/jest/coverage/lcov-report/src/components/index.html
Expand Up @@ -236,7 +236,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Expand Up @@ -352,7 +352,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/jest/coverage/lcov-report/src/layouts/index.html
Expand Up @@ -80,7 +80,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
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)
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)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down

0 comments on commit 17aff18

Please sign in to comment.