Skip to content
代码片段 群组 项目
提交 b6be84c3 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Add unit tests for UI using jsdom and standard vue testing.

上级 0d58b2bc
No related branches found
No related tags found
无相关合并请求
...@@ -16,9 +16,9 @@ module.exports = { ...@@ -16,9 +16,9 @@ module.exports = {
'<rootDir>/src-electron/**/*.js', '<rootDir>/src-electron/**/*.js',
'<rootDir>/src-shared/**/*.js', '<rootDir>/src-shared/**/*.js',
// Enable these once the UI testing is available // Enable these once the UI testing is available
//"<rootDir>/src/**/*.vue", '<rootDir>/src/**/*.vue',
//"<rootDir>/src/**/*.js", '<rootDir>/src/**/*.js',
//"<rootDir>/src/**/*.jsx", '<rootDir>/src/**/*.jsx',
], ],
coverageThreshold: { coverageThreshold: {
global: { global: {
...@@ -26,10 +26,10 @@ module.exports = { ...@@ -26,10 +26,10 @@ module.exports = {
// We need to settle on much higher number, so we will slowly // We need to settle on much higher number, so we will slowly
// be inching this upward, as we add more unit tests. // be inching this upward, as we add more unit tests.
// DO NOT EVER DECREASE THESE NUMBERS, PLEASE, UNLESS FOR A GOOD REASON. // DO NOT EVER DECREASE THESE NUMBERS, PLEASE, UNLESS FOR A GOOD REASON.
statements: 75, statements: 60,
branches: 55, branches: 45,
functions: 75, functions: 55,
lines: 75, lines: 60,
}, },
}, },
testMatch: ['<rootDir>/test/*.test.js'], testMatch: ['<rootDir>/test/*.test.js'],
......
...@@ -4280,9 +4280,9 @@ ...@@ -4280,9 +4280,9 @@
"dev": true "dev": true
}, },
"abab": { "abab": {
"version": "2.0.4", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.4.tgz", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz",
"integrity": "sha512-Eu9ELJWCz/c1e9gTiCY+FceWxcqzjYEbqMgtndnuSqZSUCOL73TWNK2mHfIj4Cw2E/ongOp+JISVNCmovt2KYQ==", "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
"dev": true "dev": true
}, },
"abbrev": { "abbrev": {
...@@ -4322,9 +4322,9 @@ ...@@ -4322,9 +4322,9 @@
}, },
"dependencies": { "dependencies": {
"acorn": { "acorn": {
"version": "7.4.0", "version": "7.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true "dev": true
} }
} }
...@@ -7951,9 +7951,9 @@ ...@@ -7951,9 +7951,9 @@
"dev": true "dev": true
}, },
"decimal.js": { "decimal.js": {
"version": "10.2.0", "version": "10.2.1",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.0.tgz", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz",
"integrity": "sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw==", "integrity": "sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==",
"dev": true "dev": true
}, },
"decode-uri-component": { "decode-uri-component": {
...@@ -15610,9 +15610,9 @@ ...@@ -15610,9 +15610,9 @@
}, },
"dependencies": { "dependencies": {
"acorn": { "acorn": {
"version": "7.4.0", "version": "7.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true "dev": true
}, },
"qs": { "qs": {
...@@ -15680,6 +15680,12 @@ ...@@ -15680,6 +15680,12 @@
} }
} }
}, },
"jsdom-global": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/jsdom-global/-/jsdom-global-3.0.2.tgz",
"integrity": "sha1-a9KZwTsMRiay2iwDk81DhdYGrLk=",
"dev": true
},
"jsesc": { "jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
...@@ -24494,9 +24500,9 @@ ...@@ -24494,9 +24500,9 @@
"dev": true "dev": true
}, },
"whatwg-url": { "whatwg-url": {
"version": "8.2.1", "version": "8.4.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.2.1.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.4.0.tgz",
"integrity": "sha512-ZmVCr6nfBeaMxEHALLEGy0LszYjpJqf6PVNQUQ1qd9Et+q7Jpygd4rGGDXgHjD8e99yLFseD69msHDM4YwPZ4A==", "integrity": "sha512-vwTUFf6V4zhcPkWp/4CQPr1TW9Ml6SF4lVyaIMBdJw5i6qUUJ1QWM4Z6YYVkfka0OUIzVo/0aNtGVGk256IKWw==",
"dev": true, "dev": true,
"requires": { "requires": {
"lodash.sortby": "^4.7.0", "lodash.sortby": "^4.7.0",
......
...@@ -15,8 +15,8 @@ limitations under the License. ...@@ -15,8 +15,8 @@ limitations under the License.
--> -->
<template> <template>
<div v-show="item"> <div v-show="item">
<div>Cluster: {{ item.label }}</div> <div>Cluster: {{ item == null ? '' : item.label }}</div>
<div>Description: {{ item.caption }}</div> <div>Description: {{ item == null ? '' : item.caption }}</div>
</div> </div>
</template> </template>
......
...@@ -130,7 +130,11 @@ export default { ...@@ -130,7 +130,11 @@ export default {
}, },
methods: { methods: {
getFormattedEndpointId(endpointRef) { getFormattedEndpointId(endpointRef) {
return '0x' + this.endpointId[endpointRef].toString(16).padStart(4, '0') if (endpointRef in this.endpointId) {
return '0x' + this.endpointId[endpointRef].toString(16).padStart(4, '0')
} else {
return ''
}
}, },
deleteEpt() { deleteEpt() {
let endpointReference = this.endpointReference let endpointReference = this.endpointReference
......
...@@ -40,15 +40,13 @@ limitations under the License. ...@@ -40,15 +40,13 @@ limitations under the License.
dense dense
/> />
</div> </div>
<div class="q-pr-lg vertical-align:middle"> <div class="q-pr-lg vertical-align:middle">Default Response Policy</div>
Default Response Policy
</div>
<q-select <q-select
:options="defaultResponsePolicyOptions" :options="defaultResponsePolicyOptions"
v-model="selectedDefaultResponsePolicy" v-model="selectedDefaultResponsePolicy"
:option-label="(item) => (item === null ? 'NULL' : item.optionLabel)" :option-label="(item) => (item === null ? 'NULL' : item.optionLabel)"
@input="handleOptionChange('defaultResponsePolicy', $event)" @input="handleOptionChange('defaultResponsePolicy', $event)"
style="width: 150px;" style="width: 150px"
outlined outlined
dense dense
/> />
...@@ -72,22 +70,26 @@ export default { ...@@ -72,22 +70,26 @@ export default {
}, },
selectedDefaultResponsePolicy: { selectedDefaultResponsePolicy: {
get() { get() {
return this.$store.state.zap.genericOptions[ var drp = this.$store.state.zap.genericOptions['defaultResponsePolicy']
'defaultResponsePolicy' if (drp == null) {
].find( return ''
(o) => } else {
o.optionCode === return drp.find(
this.$store.state.zap.selectedGenericOptions[ (o) =>
'defaultResponsePolicy' o.optionCode ===
] this.$store.state.zap.selectedGenericOptions[
) 'defaultResponsePolicy'
]
)
}
}, },
}, },
selectedManufacturerCode: { selectedManufacturerCode: {
get() { get() {
return this.$store.state.zap.genericOptions['manufacturerCodes'] == null var mc = this.$store.state.zap.genericOptions['manufacturerCodes']
return mc == null
? '' ? ''
: this.$store.state.zap.genericOptions['manufacturerCodes'].find( : mc.find(
(o) => (o) =>
o.optionCode === o.optionCode ===
this.$store.state.zap.selectedGenericOptions[ this.$store.state.zap.selectedGenericOptions[
......
...@@ -14,7 +14,5 @@ ...@@ -14,7 +14,5 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*
export function someGetter (state) { export function someGetter(state) {}
}
*/
...@@ -24,5 +24,6 @@ export function cantorPair(x, y) { ...@@ -24,5 +24,6 @@ export function cantorPair(x, y) {
} }
export function asHex(value, padding) { export function asHex(value, padding) {
if (value == null) return ''
return '0x' + value.toString(16).padStart(padding, '0').toUpperCase() return '0x' + value.toString(16).padStart(padding, '0').toUpperCase()
} }
/**
*
* Copyright (c) 2020 Silicon Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* @jest-environment jsdom
*/
import { shallowMount } from '@vue/test-utils'
import ZapStore from '../src/store/index.js'
import ZclApplicationSetup from '../src/components/ZclApplicationSetup.vue'
import ZclAttributeManager from '../src/components/ZclAttributeManager.vue'
import ZclAttributeReportingManager from '../src/components/ZclAttributeReportingManager.vue'
import ZclAttributeView from '../src/components/ZclAttributeView.vue'
import ZclClusterDetail from '../src/components/ZclClusterDetail.vue'
import ZclClusterInfo from '../src/components/ZclClusterInfo.vue'
import ZclClusterList from '../src/components/ZclClusterList.vue'
import ZclClusterManager from '../src/components/ZclClusterManager.vue'
import ZclClusterView from '../src/components/ZclClusterView.vue'
import ZclCommandManager from '../src/components/ZclCommandManager.vue'
import ZclCommandView from '../src/components/ZclCommandView.vue'
import ZclCreateModifyEndpoint from '../src/components/ZclCreateModifyEndpoint.vue'
import ZclCustomSetup from '../src/components/ZclCustomSetup.vue'
import ZclDomainClusterView from '../src/components/ZclDomainClusterView.vue'
import ZclEndpointCard from '../src/components/ZclEndpointCard.vue'
import ZclEndpointConfig from '../src/components/ZclEndpointConfig.vue'
import ZclEndpointManager from '../src/components/ZclEndpointManager.vue'
import ZclEndpointTypeConfig from '../src/components/ZclEndpointTypeConfig.vue'
import ZclGeneralOptionsBar from '../src/components/ZclGeneralOptionsBar.vue'
import ZclInformationSetup from '../src/components/ZclInformationSetup.vue'
import ZclReportingView from '../src/components/ZclReportingView.vue'
test('ZclApplicationSetup', () => {
const wrapper = shallowMount(ZclApplicationSetup, { store: ZapStore() })
expect(wrapper.html().includes('application setup')).toBe(true)
})
test('ZclAttributeManager', () => {
const wrapper = shallowMount(ZclAttributeManager, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclAttributeReportingManager', () => {
const wrapper = shallowMount(ZclAttributeReportingManager, {
store: ZapStore(),
})
expect(ZclAttributeReportingManager.data()).not.toBe(null)
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclAttributeView', () => {
const wrapper = shallowMount(ZclAttributeView, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclClusterDetail', () => {
const wrapper = shallowMount(ZclClusterDetail, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclClusterInfo', () => {
const wrapper = shallowMount(ZclClusterInfo, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(50)
})
test('ZclClusterList', () => {
const wrapper = shallowMount(ZclClusterList, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclClusterManager', () => {
const wrapper = shallowMount(ZclClusterManager, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclClusterView', () => {
const wrapper = shallowMount(ZclClusterView, { store: ZapStore() })
expect(wrapper.html().includes('Endpoint')).toBe(true)
})
test('ZclCommandManager', () => {
const wrapper = shallowMount(ZclCommandManager, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclCommandView', () => {
const wrapper = shallowMount(ZclCommandView, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclCreateModifyEndpoint', () => {
const wrapper = shallowMount(ZclCreateModifyEndpoint, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclCustomSetup', () => {
const wrapper = shallowMount(ZclCustomSetup, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(50)
})
test('ZclDomainClusterView', () => {
const wrapper = shallowMount(ZclDomainClusterView, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclEndpointCard', () => {
const wrapper = shallowMount(ZclEndpointCard, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclEndpointConfig', () => {
const wrapper = shallowMount(ZclEndpointConfig, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclEndpointManager', () => {
const wrapper = shallowMount(ZclEndpointManager, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclEndpointTypeConfig', () => {
const wrapper = shallowMount(ZclEndpointTypeConfig, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclGeneralOptionsBar', () => {
const wrapper = shallowMount(ZclGeneralOptionsBar, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclInformationSetup', () => {
const wrapper = shallowMount(ZclInformationSetup, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
test('ZclReportingView', () => {
const wrapper = shallowMount(ZclReportingView, { store: ZapStore() })
expect(wrapper.html().length).toBeGreaterThan(100)
})
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册