TT#103201 Close call forwarding condition popups if opening other popups or menus

Change-Id: Ie523cc0bb7de3c36564f45060a1bd8e2f92f852d
pull/4/head
Hans-Peter Herzog 5 years ago
parent e4c421e1d9
commit 239466fcb5

@ -1,5 +1,5 @@
const fs = require('fs-extra') const fs = require('fs-extra')
let extend = undefined let extend
/** /**
* The .babelrc file has been created to assist Jest for transpiling. * The .babelrc file has been created to assist Jest for transpiling.

@ -1,5 +1,7 @@
<template> <template>
<q-popup-proxy> <q-popup-proxy
@before-show="$store.commit('callForwarding/popupShow', null)"
>
<q-list <q-list
v-bind="$attrs" v-bind="$attrs"
class="bg-dark" class="bg-dark"

@ -0,0 +1,66 @@
<template>
<q-popup-proxy
ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
v-on="$listeners"
>
<slot />
</q-popup-proxy>
</template>
<script>
import _ from 'lodash'
import {
v4
} from 'uuid'
import {
mapState,
mapMutations
} from 'vuex'
export default {
name: 'CscCfConditionPopup',
data () {
return {
popupId: _.kebabCase(this.$options.name) + '-' + v4()
}
},
computed: {
...mapState('callForwarding', [
'popupCurrent'
])
},
watch: {
popupCurrent (id) {
if (id === null || this.popupId !== id) {
this.close()
}
}
},
methods: {
...mapMutations('callForwarding', [
'popupShow'
]),
beforeShow () {
this.closed = false
this.popupShow(this.popupId)
},
close () {
this.closed = true
this.$refs.popup.hide()
this.$emit('close')
},
reOpen () {
if (!this.closed) {
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
this.$emit('open')
})
}
}
}
}
</script>

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-menu <csc-cf-group-condition-menu
v-if="internalStep === 'menu'" v-if="internalStep === 'menu'"
@ -111,11 +107,10 @@
:destination-set="destinationSet" :destination-set="destinationSet"
:source-set="sourceSet" :source-set="sourceSet"
:time-set="timeSet" :time-set="timeSet"
@navigate="navigate"
@back="internalStep='menu'" @back="internalStep='menu'"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
@ -126,9 +121,11 @@ import CscCfGroupConditionDate from 'components/call-forwarding/CscCfGroupCondit
import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange' import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange'
import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays' import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays'
import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours' import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupAll', name: 'CscCfConditionPopupAll',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionOfficeHours, CscCfGroupConditionOfficeHours,
CscCfGroupConditionWeekdays, CscCfGroupConditionWeekdays,
CscCfGroupConditionDateRange, CscCfGroupConditionDateRange,
@ -161,41 +158,18 @@ export default {
}, },
data () { data () {
return { return {
closed: false, internalStep: this.step
internalStep: this.step,
selectedSourceSet: null
} }
}, },
watch: { watch: {
internalStep () { internalStep () {
if (!this.closed) { this.$refs.popup.reOpen()
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true
this.internalStep = 'menu' this.internalStep = 'menu'
this.$refs.popup.hide() this.$refs.popup.close()
},
openPopup () {
if (!this.closed) {
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
},
navigate (step) {
this.internalStep = step
this.openPopup()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-source-set-create <csc-cf-group-condition-source-set-create
v-if="internalStep === 'call-from'" v-if="internalStep === 'call-from'"
@ -36,15 +32,17 @@
@create="internalStep='call-from'" @create="internalStep='call-from'"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate' import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate'
import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect' import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupCallFrom', name: 'CscCfConditionPopupCallFrom',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionSourceSetSelect, CscCfGroupConditionSourceSetSelect,
CscCfGroupConditionSourceSetCreate CscCfGroupConditionSourceSetCreate
}, },
@ -74,22 +72,13 @@ export default {
}, },
watch: { watch: {
internalStep () { internalStep () {
if (!this.closed) { this.$refs.popup.reOpen()
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true
this.internalStep = 'call-from' this.internalStep = 'call-from'
this.$refs.popup.hide() this.$refs.popup.close()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-source-set-create <csc-cf-group-condition-source-set-create
v-if="internalStep === 'call-not-from'" v-if="internalStep === 'call-not-from'"
@ -36,15 +32,17 @@
@create="internalStep='call-not-from'" @create="internalStep='call-not-from'"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate' import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate'
import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect' import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupCallNotFrom', name: 'CscCfConditionPopupCallNotFrom',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionSourceSetSelect, CscCfGroupConditionSourceSetSelect,
CscCfGroupConditionSourceSetCreate CscCfGroupConditionSourceSetCreate
}, },
@ -74,22 +72,13 @@ export default {
}, },
watch: { watch: {
internalStep () { internalStep () {
if (!this.closed) { this.$refs.popup.reOpen()
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true
this.internalStep = 'call-not-from' this.internalStep = 'call-not-from'
this.$refs.popup.hide() this.$refs.popup.close()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-date <csc-cf-group-condition-date
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionDate from 'components/call-forwarding/CscCfGroupConditionDate' import CscCfGroupConditionDate from 'components/call-forwarding/CscCfGroupConditionDate'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupDate', name: 'CscCfConditionPopupDate',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionDate CscCfGroupConditionDate
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-date-range <csc-cf-group-condition-date-range
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange' import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupDateRange', name: 'CscCfConditionPopupDateRange',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionDateRange CscCfGroupConditionDateRange
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-office-hours <csc-cf-group-condition-office-hours
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours' import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupOfficeHours', name: 'CscCfConditionPopupOfficeHours',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionOfficeHours CscCfGroupConditionOfficeHours
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-weekdays <csc-cf-group-condition-weekdays
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays' import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupWeekdays', name: 'CscCfConditionPopupWeekdays',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionWeekdays CscCfGroupConditionWeekdays
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -32,6 +32,7 @@
<q-popup-edit <q-popup-edit
v-model="changedDestinationTimeout" v-model="changedDestinationTimeout"
buttons buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateRingTimeoutEvent()" @save="updateRingTimeoutEvent()"
> >
<csc-input <csc-input
@ -67,6 +68,7 @@
<q-popup-edit <q-popup-edit
v-model="changedDestinationTimeout" v-model="changedDestinationTimeout"
buttons buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateDestinationTimeoutEvent({ @save="updateDestinationTimeoutEvent({
destinationTimeout: changedDestinationTimeout, destinationTimeout: changedDestinationTimeout,
destinationIndex: destinationIndex - 1, destinationIndex: destinationIndex - 1,
@ -152,6 +154,7 @@
<q-popup-edit <q-popup-edit
v-model="changedDestination" v-model="changedDestination"
buttons buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateDestinationEvent({ @save="updateDestinationEvent({
destination: changedDestination, destination: changedDestination,
destinationIndex: destinationIndex, destinationIndex: destinationIndex,

@ -27,3 +27,7 @@ export function dataSucceeded (state, res) {
state.mappings = res.mappings state.mappings = res.mappings
} }
} }
export function popupShow (state, popupId) {
state.popupCurrent = popupId
}

@ -15,6 +15,7 @@ export default function () {
sourceSets: null, sourceSets: null,
sourceSetMap: {}, sourceSetMap: {},
timeSets: null, timeSets: null,
timeSetMap: {} timeSetMap: {},
popupCurrent: null
} }
} }

@ -1,7 +1,7 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { import {
enableIncomingCallBlocking, enableIncomingCallBlocking,
disableIncomingCallBlocking, disableIncomingCallBlocking,
@ -15,296 +15,295 @@ import {
addNumberToOutgoingList, addNumberToOutgoingList,
editNumberFromOutgoingList, editNumberFromOutgoingList,
removeNumberFromOutgoingList removeNumberFromOutgoingList
} from '../../src/api/call-blocking'; } from '../../src/api/call-blocking'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('CallBlocking', function(){ describe('CallBlocking', function () {
var subscriberId = 123
var subscriberId = 123; beforeEach(function () {
Vue.http.interceptors = []
})
beforeEach(function(){ describe('Incoming', function () {
Vue.http.interceptors = []; it('should enable call blocking for incoming calls', function (done) {
}); Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
describe('Incoming', function(){ assert.equal(request.body[0].op, 'replace')
it('should enable call blocking for incoming calls', function(done) { assert.equal(request.body[0].path, '/block_in_mode')
Vue.http.interceptors.unshift((request, next)=>{ assert.equal(request.body[0].value, true)
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
assert.equal(request.body[0].op, 'replace');
assert.equal(request.body[0].path, '/block_in_mode');
assert.equal(request.body[0].value, true);
next(request.respondWith('', { next(request.respondWith('', {
status: 204 status: 204
})); }))
}); })
enableIncomingCallBlocking(subscriberId).then(()=>{ enableIncomingCallBlocking(subscriberId).then(() => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should disable call blocking for incoming calls', function(done) { it('should disable call blocking for incoming calls', function (done) {
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.body[0].op, 'replace'); assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].path, '/block_in_mode'); assert.equal(request.body[0].path, '/block_in_mode')
assert.equal(request.body[0].value, false); assert.equal(request.body[0].value, false)
next(request.respondWith('', { next(request.respondWith('', {
status: 204 status: 204
})); }))
}); })
disableIncomingCallBlocking(subscriberId).then(()=>{ disableIncomingCallBlocking(subscriberId).then(() => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should get all data regarding incoming call blocking', function(done){ it('should get all data regarding incoming call blocking', function (done) {
var list = [ var list = [
"0123456789", '0123456789',
"0987654321" '0987654321'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_in_list" : list, block_in_list: list,
"block_in_mode" : true block_in_mode: true
}), { }), {
status: 200 status: 200
})); }))
}); })
getIncomingCallBlocking(subscriberId).then((result)=>{ getIncomingCallBlocking(subscriberId).then((result) => {
assert.deepEqual(result.list, list); assert.deepEqual(result.list, list)
assert.equal(result.enabled, true); assert.equal(result.enabled, true)
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should add a new number to incoming call blocking list', function(done){ it('should add a new number to incoming call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_in_list" : list block_in_list: list
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [].concat([number], list)); assert.deepEqual(request.body.block_in_list, [].concat([number], list))
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
addNumberToIncomingList(subscriberId, number).then((result)=>{ addNumberToIncomingList(subscriberId, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should edit a number from incoming call blocking list', function(done){ it('should edit a number from incoming call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_in_list" : list block_in_list: list
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [number]); assert.deepEqual(request.body.block_in_list, [number])
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
editNumberFromIncomingList(subscriberId, 0, number).then((result)=>{ editNumberFromIncomingList(subscriberId, 0, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should remove a number from incoming call blocking list', function(done){ it('should remove a number from incoming call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_in_list" : [].concat([number]).concat(list) block_in_list: [].concat([number]).concat(list)
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, list); assert.deepEqual(request.body.block_in_list, list)
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
removeNumberFromIncomingList(subscriberId, 0, number).then((result)=>{ removeNumberFromIncomingList(subscriberId, 0, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
}); })
describe('Outgoing', function(){ describe('Outgoing', function () {
it('should enable call blocking for outgoing calls', function(done) { it('should enable call blocking for outgoing calls', function (done) {
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.body[0].op, 'replace'); assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].path, '/block_out_mode'); assert.equal(request.body[0].path, '/block_out_mode')
assert.equal(request.body[0].value, true); assert.equal(request.body[0].value, true)
next(request.respondWith('', { next(request.respondWith('', {
status: 204 status: 204
})); }))
}); })
enableOutgoingCallBlocking(subscriberId).then(()=>{ enableOutgoingCallBlocking(subscriberId).then(() => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should disable call blocking for outgoing calls', function(done) { it('should disable call blocking for outgoing calls', function (done) {
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.body[0].op, 'replace'); assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].path, '/block_out_mode'); assert.equal(request.body[0].path, '/block_out_mode')
assert.equal(request.body[0].value, false); assert.equal(request.body[0].value, false)
next(request.respondWith('', { next(request.respondWith('', {
status: 204 status: 204
})); }))
}); })
disableOutgoingCallBlocking(subscriberId).then(()=>{ disableOutgoingCallBlocking(subscriberId).then(() => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should get all data regarding outgoing call blocking', function(done){ it('should get all data regarding outgoing call blocking', function (done) {
var list = [ var list = [
"0123456789", '0123456789',
"0987654321" '0987654321'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_out_list" : list, block_out_list: list,
"block_out_mode" : true block_out_mode: true
}), { }), {
status: 200 status: 200
})); }))
}); })
getOutgoingCallBlocking(subscriberId).then((result)=>{ getOutgoingCallBlocking(subscriberId).then((result) => {
assert.deepEqual(result.list, list); assert.deepEqual(result.list, list)
assert.equal(result.enabled, true); assert.equal(result.enabled, true)
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should add a new number to outgoing call blocking list', function(done){ it('should add a new number to outgoing call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_out_list" : list block_out_list: list
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [].concat([number], list)); assert.deepEqual(request.body.block_out_list, [].concat([number], list))
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
addNumberToOutgoingList(subscriberId, number).then((result)=>{ addNumberToOutgoingList(subscriberId, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should edit a number from outgoing call blocking list', function(done){ it('should edit a number from outgoing call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_out_list" : list block_out_list: list
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [number]); assert.deepEqual(request.body.block_out_list, [number])
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
editNumberFromOutgoingList(subscriberId, 0, number).then((result)=>{ editNumberFromOutgoingList(subscriberId, 0, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should remove a number from outgoing call blocking list', function(done){ it('should remove a number from outgoing call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_out_list" : [].concat([number]).concat(list) block_out_list: [].concat([number]).concat(list)
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, list); assert.deepEqual(request.body.block_out_list, list)
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
removeNumberFromOutgoingList(subscriberId, 0).then(()=>{ removeNumberFromOutgoingList(subscriberId, 0).then(() => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
}); })
}); })

File diff suppressed because it is too large Load Diff

@ -1,97 +1,94 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import crypto from 'crypto-browserify' import crypto from 'crypto-browserify'
import { getConversations } from '../../src/api/conversations'; import { getConversations } from '../../src/api/conversations'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('Conversations', function(){ describe('Conversations', function () {
const subscriberId = 123
const subscriberId = 123; it('should get all data regarding conversations', function (done) {
const innerData = [{
it('should get all data regarding conversations', function(done){ _links: {
collection: {
let innerData = [{ href: '/api/conversations/'
"_links" : {
"collection": {
"href": "/api/conversations/"
}, },
"curies": { curies: {
"href": "http://purl.org/sipwise/ngcp-api/#rel-{rel}", href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
"name": "ngcp", name: 'ngcp',
"templated": true templated: true
}, },
"ngcp:conversations": { 'ngcp:conversations': {
"href": "/api/conversations/1?type=voicemail" href: '/api/conversations/1?type=voicemail'
}, },
"ngcp:voicemailrecordings": { 'ngcp:voicemailrecordings': {
"href": "/api/voicemailrecordings/1" href: '/api/voicemailrecordings/1'
}, },
"ngcp:voicemails": { 'ngcp:voicemails': {
"href": "/api/voicemails/1" href: '/api/voicemails/1'
}, },
"profile": { profile: {
"href": "http://purl.org/sipwise/ngcp-api/" href: 'http://purl.org/sipwise/ngcp-api/'
}, },
"self": { self: {
"href": "/api/conversations/1?type=voicemail" href: '/api/conversations/1?type=voicemail'
} }
}, },
"call_id": "kp55kEGtNp", call_id: 'kp55kEGtNp',
"callee": "43993006", callee: '43993006',
"caller": "43993006", caller: '43993006',
"context": "voicemailcaller_unavail", context: 'voicemailcaller_unavail',
"direction": "in", direction: 'in',
"duration": "15", duration: '15',
"filename": "voicemail-0.wav", filename: 'voicemail-0.wav',
"folder": "Old", folder: 'Old',
"id": 1, id: 1,
"start_time": "2017-12-07 16:22:04", start_time: '2017-12-07 16:22:04',
"type": "voicemail", type: 'voicemail',
"voicemail_subscriber_id": 235 voicemail_subscriber_id: 235
}]; }]
let data = { const data = {
"_embedded": { _embedded: {
"ngcp:conversations": innerData 'ngcp:conversations': innerData
}, },
total_count: 1 total_count: 1
}; }
let innerDataTransformed = { const innerDataTransformed = {
items: [{ items: [{
"call_id": "kp55kEGtNp", call_id: 'kp55kEGtNp',
"callee": "43993006", callee: '43993006',
"caller": "43993006", caller: '43993006',
"context": "voicemailcaller_unavail", context: 'voicemailcaller_unavail',
"direction": "in", direction: 'in',
"duration": "15", duration: '15',
"filename": "voicemail-0.wav", filename: 'voicemail-0.wav',
"folder": "Old", folder: 'Old',
"id": 1, id: 1,
"start_time": "2017-12-07 16:22:04", start_time: '2017-12-07 16:22:04',
"type": "voicemail", type: 'voicemail',
"voicemail_subscriber_id": 235 voicemail_subscriber_id: 235
}], }],
lastPage: 1 lastPage: 1
}; }
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), { next(request.respondWith(JSON.stringify(data), {
status: 200 status: 200
})); }))
}); })
getConversations(subscriberId).then((result)=>{ getConversations(subscriberId).then((result) => {
assert.deepEqual(result, innerDataTransformed); assert.deepEqual(result, innerDataTransformed)
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
})
});

@ -1,196 +1,192 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { import {
getFieldList getFieldList
} from '../../src/api/common'; } from '../../src/api/common'
import { import {
getSpeedDialsById, getSpeedDialsById,
getUnassignedSlots getUnassignedSlots
} from '../../src/api/speed-dial'; } from '../../src/api/speed-dial'
import { assert } from 'chai'; import { assert } from 'chai'
import { i18n } from '../../src/i18n'; import { i18n } from '../../src/i18n'
Vue.use(VueResource); Vue.use(VueResource)
describe('SpeedDial', function(){ describe('SpeedDial', function () {
const subscriberId = 123
const subscriberId = 123; it('should get list of subscriber specific speed dials', function (done) {
const data = {
it('should get list of subscriber specific speed dials', function(done){ _links: {
collection: {
let data = { href: '/api/speeddials/'
"_links" : {
"collection" : {
"href" : "/api/speeddials/"
}, },
"curies" : { curies: {
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}", href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
"name" : "ngcp", name: 'ngcp',
"templated" : true templated: true
}, },
"ngcp:journal" : [ 'ngcp:journal': [
{ {
"href" : "/api/speeddials/323/journal/" href: '/api/speeddials/323/journal/'
} }
], ],
"ngcp:speeddials" : [ 'ngcp:speeddials': [
{ {
"href" : "/api/speeddials/323" href: '/api/speeddials/323'
} }
], ],
"ngcp:subscribers" : [ 'ngcp:subscribers': [
{ {
"href" : "/api/subscribers/323" href: '/api/subscribers/323'
} }
], ],
"profile" : { profile: {
"href" : "http://purl.org/sipwise/ngcp-api/" href: 'http://purl.org/sipwise/ngcp-api/'
}, },
"self" : { self: {
"href" : "/api/speeddials/323" href: '/api/speeddials/323'
} }
}, },
"speeddials" : [ speeddials: [
{ {
"destination" : "sip:439965050@192.168.178.23", destination: 'sip:439965050@192.168.178.23',
"slot" : "*9" slot: '*9'
}, },
{ {
"destination" : "sip:22222222@192.168.178.23", destination: 'sip:22222222@192.168.178.23',
"slot" : "*0" slot: '*0'
}, },
{ {
"destination" : "sip:43665522@192.168.178.23", destination: 'sip:43665522@192.168.178.23',
"slot" : "*3" slot: '*3'
} }
] ]
}; }
let fieldList = [ const fieldList = [
{ {
"destination" : "sip:22222222@192.168.178.23", destination: 'sip:22222222@192.168.178.23',
"slot" : "*0" slot: '*0'
}, },
{ {
"destination" : "sip:43665522@192.168.178.23", destination: 'sip:43665522@192.168.178.23',
"slot" : "*3" slot: '*3'
}, },
{ {
"destination" : "sip:439965050@192.168.178.23", destination: 'sip:439965050@192.168.178.23',
"slot" : "*9" slot: '*9'
} }
]; ]
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), { next(request.respondWith(JSON.stringify(data), {
status: 200 status: 200
})); }))
}); })
getSpeedDialsById(subscriberId).then((result)=>{ getSpeedDialsById(subscriberId).then((result) => {
assert.deepEqual(result, fieldList); assert.deepEqual(result, fieldList)
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should get list of unassigned speed dial slots', function(done){ it('should get list of unassigned speed dial slots', function (done) {
const data = {
let data = { _links: {
"_links" : { collection: {
"collection" : { href: '/api/speeddials/'
"href" : "/api/speeddials/"
}, },
"curies" : { curies: {
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}", href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
"name" : "ngcp", name: 'ngcp',
"templated" : true templated: true
}, },
"ngcp:journal" : [ 'ngcp:journal': [
{ {
"href" : "/api/speeddials/323/journal/" href: '/api/speeddials/323/journal/'
} }
], ],
"ngcp:speeddials" : [ 'ngcp:speeddials': [
{ {
"href" : "/api/speeddials/323" href: '/api/speeddials/323'
} }
], ],
"ngcp:subscribers" : [ 'ngcp:subscribers': [
{ {
"href" : "/api/subscribers/323" href: '/api/subscribers/323'
} }
], ],
"profile" : { profile: {
"href" : "http://purl.org/sipwise/ngcp-api/" href: 'http://purl.org/sipwise/ngcp-api/'
}, },
"self" : { self: {
"href" : "/api/speeddials/323" href: '/api/speeddials/323'
} }
}, },
"speeddials" : [ speeddials: [
{ {
"destination" : "sip:439965050@192.168.178.23", destination: 'sip:439965050@192.168.178.23',
"slot" : "*9" slot: '*9'
}, },
{ {
"destination" : "sip:22222222@192.168.178.23", destination: 'sip:22222222@192.168.178.23',
"slot" : "*0" slot: '*0'
}, },
{ {
"destination" : "sip:43665522@192.168.178.23", destination: 'sip:43665522@192.168.178.23',
"slot" : "*3" slot: '*3'
} }
] ]
}; }
let slotOptions = [ const slotOptions = [
{ {
"label" : i18n.t('speedDial.slot').concat(" *1"), label: i18n.t('speedDial.slot').concat(' *1'),
"value" : "*1" value: '*1'
}, },
{ {
"label" : i18n.t('speedDial.slot').concat(" *2"), label: i18n.t('speedDial.slot').concat(' *2'),
"value" : "*2" value: '*2'
}, },
{ {
"label" : i18n.t('speedDial.slot').concat(" *4"), label: i18n.t('speedDial.slot').concat(' *4'),
"value" : "*4" value: '*4'
}, },
{ {
"label" : i18n.t('speedDial.slot').concat(" *5"), label: i18n.t('speedDial.slot').concat(' *5'),
"value" : "*5" value: '*5'
}, },
{ {
"label" : i18n.t('speedDial.slot').concat(" *6"), label: i18n.t('speedDial.slot').concat(' *6'),
"value" : "*6" value: '*6'
}, },
{ {
"label" : i18n.t('speedDial.slot').concat(" *7"), label: i18n.t('speedDial.slot').concat(' *7'),
"value" : "*7" value: '*7'
}, },
{ {
"label" : i18n.t('speedDial.slot').concat(" *8"), label: i18n.t('speedDial.slot').concat(' *8'),
"value" : "*8" value: '*8'
} }
]; ]
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), { next(request.respondWith(JSON.stringify(data), {
status: 200 status: 200
})); }))
}); })
getUnassignedSlots(subscriberId).then((result)=>{ getUnassignedSlots(subscriberId).then((result) => {
assert.deepEqual(result, slotOptions); assert.deepEqual(result, slotOptions)
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
})
});

@ -1,52 +1,51 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { getPreferences } from '../../src/api/subscriber'; import { getPreferences } from '../../src/api/subscriber'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('Subscriber', function(){ describe('Subscriber', function () {
const subscriberId = 123
const subscriberId = 123; it('should get all subscriber preferences', function (done) {
Vue.http.interceptors = []
it('should get all subscriber preferences', function(done) { Vue.http.interceptors.unshift((request, next) => {
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
block_in_mode: false, block_in_mode: false,
clir: false clir: false
}), { }), {
status: 200 status: 200
})); }))
}); })
getPreferences(subscriberId).then((result)=>{ getPreferences(subscriberId).then((result) => {
assert.property(result, 'block_in_mode'); assert.property(result, 'block_in_mode')
assert.isFalse(result.block_in_mode); assert.isFalse(result.block_in_mode)
assert.property(result, 'clir'); assert.property(result, 'clir')
assert.isFalse(result.clir); assert.isFalse(result.clir)
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should handle a 403 Forbidden while requesting the preferences', function(done) { it('should handle a 403 Forbidden while requesting the preferences', function (done) {
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
message: '403 Forbidden' message: '403 Forbidden'
}), { }), {
status: 403 status: 403
})); }))
}); })
getPreferences(subscriberId).then(()=>{ getPreferences(subscriberId).then(() => {
done(new Error('Test failed')); done(new Error('Test failed'))
}).catch((err)=>{ }).catch((err) => {
assert.equal(err.status, 403); assert.equal(err.status, 403)
done(); done()
}); })
}); })
}); })

@ -1,152 +1,147 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { import {
get, get,
getList getList
} from '../../src/api/common'; } from '../../src/api/common'
import { import {
getVoiceboxSettings, getVoiceboxSettings,
getVoiceboxGreetingByType getVoiceboxGreetingByType
} from '../../src/api/voicebox'; } from '../../src/api/voicebox'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('Voicebox', function() { describe('Voicebox', function () {
const subscriberId = 123
const subscriberId = 123; it('should get subscriber\'s voicebox settings', function (done) {
const data = {
it('should get subscriber\'s voicebox settings', function(done) { _links: {
collection: {
let data = { href: '/api/voicemailsettings/'
"_links" : {
"collection" : {
"href" : "/api/voicemailsettings/"
}, },
"curies" : { curies: {
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}", href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
"name" : "ngcp", name: 'ngcp',
"templated" : true templated: true
}, },
"ngcp:journal" : [ 'ngcp:journal': [
{ {
"href" : "/api/voicemailsettings/123/journal/" href: '/api/voicemailsettings/123/journal/'
} }
], ],
"ngcp:subscribers" : [ 'ngcp:subscribers': [
{ {
"href" : "/api/subscribers/123" href: '/api/subscribers/123'
} }
], ],
"profile" : { profile: {
"href" : "http://purl.org/sipwise/ngcp-api/" href: 'http://purl.org/sipwise/ngcp-api/'
}, },
"self" : { self: {
"href" : "/api/voicemailsettings/123" href: '/api/voicemailsettings/123'
} }
}, },
"attach" : true, attach: true,
"delete" : false, delete: false,
"email" : "", email: '',
"id" : 123, id: 123,
"pin" : "1234", pin: '1234',
"sms_number" : "" sms_number: ''
}; }
let settings = { const settings = {
"attach" : true, attach: true,
"delete" : false, delete: false,
"email" : "", email: '',
"id" : 123, id: 123,
"pin" : "1234", pin: '1234',
"sms_number" : "" sms_number: ''
}; }
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => { Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), { next(request.respondWith(JSON.stringify(data), {
status: 200 status: 200
})); }))
}); })
getVoiceboxSettings(subscriberId).then((result) => { getVoiceboxSettings(subscriberId).then((result) => {
assert.deepEqual(result, settings); assert.deepEqual(result, settings)
done(); done()
}).catch((err) => { }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should get subscriber\'s busy greeting', function(done) { it('should get subscriber\'s busy greeting', function (done) {
const data = {
let data = { _embedded: {
"_embedded" : { 'ngcp:voicemailgreetings': [
"ngcp:voicemailgreetings" : [
{ {
"dir" : "busy", dir: 'busy',
"id" : 1, id: 1,
"subscriber_id" : 123 subscriber_id: 123
} }
] ]
}, },
"total_count" : 1 total_count: 1
}; }
let greeting = { const greeting = {
"dir" : "busy", dir: 'busy',
"id" : 1, id: 1,
"subscriber_id" : 123 subscriber_id: 123
}; }
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => { Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), { next(request.respondWith(JSON.stringify(data), {
status: 200 status: 200
})); }))
}); })
getVoiceboxGreetingByType({id: subscriberId, type: 'busy'}).then((result) => { getVoiceboxGreetingByType({ id: subscriberId, type: 'busy' }).then((result) => {
assert.deepEqual(result.items[0], greeting); assert.deepEqual(result.items[0], greeting)
done(); done()
}).catch((err) => { }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should get subscriber\'s unavailable greeting', function(done) { it('should get subscriber\'s unavailable greeting', function (done) {
const data = {
let data = { _embedded: {
"_embedded" : { 'ngcp:voicemailgreetings': [
"ngcp:voicemailgreetings" : [
{ {
"dir" : "unavail", dir: 'unavail',
"id" : 1, id: 1,
"subscriber_id" : 123 subscriber_id: 123
} }
] ]
}, },
"total_count" : 1 total_count: 1
}; }
let greeting = { const greeting = {
"dir" : "unavail", dir: 'unavail',
"id" : 1, id: 1,
"subscriber_id" : 123 subscriber_id: 123
}; }
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => { Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), { next(request.respondWith(JSON.stringify(data), {
status: 200 status: 200
})); }))
}); })
getVoiceboxGreetingByType({id: subscriberId, type: 'unavail'}).then((result) => { getVoiceboxGreetingByType({ id: subscriberId, type: 'unavail' }).then((result) => {
assert.deepEqual(result.items[0], greeting); assert.deepEqual(result.items[0], greeting)
done(); done()
}).catch((err) => { }).catch((err) => {
done(err); done(err)
}); })
}); })
})
});

@ -1,13 +1,12 @@
import Vue from 'vue' import Vue from 'vue'
import Login from '../../src/components/Login.vue' import Login from '../../src/components/Login.vue'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Login', function() { describe('Login', function () {
it('should initialize with default data', function () {
it('should initialize with default data', function(){ var defaultData = Login.data()
var defaultData = Login.data(); assert.equal(defaultData.username, '')
assert.equal(defaultData.username, ''); assert.equal(defaultData.password, '')
assert.equal(defaultData.password, ''); })
}); })
});

@ -1,65 +1,62 @@
'use strict'; 'use strict'
import CallBlockingModule from '../../src/store/call-blocking'; import CallBlockingModule from '../../src/store/call-blocking'
import { assert } from 'chai'; import { assert } from 'chai'
describe('CallBlocking', function(){ describe('CallBlocking', function () {
describe('Incoming', function () {
describe('Incoming', function(){ it('should enable list', function () {
var state = {}
it('should enable list', function(){ CallBlockingModule.mutations.toggleSucceeded(state, true)
var state = {}; assert.equal(state.enabled, true)
CallBlockingModule.mutations.toggleSucceeded(state, true); })
assert.equal(state.enabled, true);
}); it('should disable list', function () {
var state = {}
it('should disable list', function(){ CallBlockingModule.mutations.toggleSucceeded(state, false)
var state = {}; assert.equal(state.enabled, false)
CallBlockingModule.mutations.toggleSucceeded(state, false); })
assert.equal(state.enabled, false);
}); it('should load list and flag', function () {
var state = {}
it('should load list and flag', function(){
var state = {};
var list = [ var list = [
'0123456789', '0123456789',
'0987654321' '0987654321'
]; ]
CallBlockingModule.mutations.numberListSucceeded(state, { CallBlockingModule.mutations.numberListSucceeded(state, {
enabled: true, enabled: true,
list: list list: list
}); })
assert.equal(state.enabled, true); assert.equal(state.enabled, true)
assert.deepEqual(state.list, list); assert.deepEqual(state.list, list)
}); })
}); })
describe('Outgoing', function(){ describe('Outgoing', function () {
it('should enable list', function () {
it('should enable list', function(){ var state = {}
var state = {}; CallBlockingModule.mutations.toggleSucceeded(state, true)
CallBlockingModule.mutations.toggleSucceeded(state, true); assert.equal(state.enabled, true)
assert.equal(state.enabled, true); })
});
it('should disable list', function () {
it('should disable list', function(){ var state = {}
var state = {}; CallBlockingModule.mutations.toggleSucceeded(state, false)
CallBlockingModule.mutations.toggleSucceeded(state, false); assert.equal(state.enabled, false)
assert.equal(state.enabled, false); })
});
it('should load list and flag', function () {
it('should load list and flag', function(){ var state = {}
var state = {};
var list = [ var list = [
'0123456789', '0123456789',
'0987654321' '0987654321'
]; ]
CallBlockingModule.mutations.numberListSucceeded(state, { CallBlockingModule.mutations.numberListSucceeded(state, {
enabled: true, enabled: true,
list: list list: list
}); })
assert.equal(state.enabled, true); assert.equal(state.enabled, true)
assert.deepEqual(state.list, list); assert.deepEqual(state.list, list)
}); })
}); })
}); })

@ -1,54 +1,53 @@
'use strict'; 'use strict'
import CallForwardModule from '../../src/store/call-forward'; import CallForwardModule from '../../src/store/call-forward'
import { assert } from 'chai'; import { assert } from 'chai'
describe('CallForward', function(){ describe('CallForward', function () {
it('should load always type destinations', function () {
it('should load always type destinations', function(){ const state = {
let state = {
destinations: { destinations: {
online: [], online: [],
busy: [], busy: [],
offline: [] offline: []
} }
}; }
let data = { const data = {
online: [], online: [],
busy: [], busy: [],
offline: [{ offline: [{
destinations: [{ destinations: [{
"announcement_id": null, announcement_id: null,
"destination": "sip:3333@192.168.178.23", destination: 'sip:3333@192.168.178.23',
"priority": 1, priority: 1,
"simple_destination": "3333", simple_destination: '3333',
"timeout": 60 timeout: 60
}, },
{ {
"announcement_id": null, announcement_id: null,
"destination": "sip:2222@192.168.178.23", destination: 'sip:2222@192.168.178.23',
"priority": 1, priority: 1,
"simple_destination": "2222", simple_destination: '2222',
"timeout": 300 timeout: 300
}], }],
id: 3, id: 3,
name: "csc_destinationset_1" name: 'csc_destinationset_1'
}] }]
}; }
CallForwardModule.mutations.loadDestinations(state, data); CallForwardModule.mutations.loadDestinations(state, data)
assert.deepEqual(state.destinations, data); assert.deepEqual(state.destinations, data)
}); })
it('should load timeset times', function(){ it('should load timeset times', function () {
let state = { const state = {
timesetTimes: [] timesetTimes: []
}; }
let result = { const result = {
times: [ times: [
{ weekday: "Monday", from: "8", to: "16" }, { weekday: 'Monday', from: '8', to: '16' },
{ weekday: "Tuesday", from: "8", to: "16" }, { weekday: 'Tuesday', from: '8', to: '16' },
{ weekday: "Wednesday", from: "8", to: "16" } { weekday: 'Wednesday', from: '8', to: '16' }
], ],
timesetIsCompatible: null, timesetIsCompatible: null,
timesetExists: null, timesetExists: null,
@ -56,8 +55,7 @@ describe('CallForward', function(){
timesetHasDuplicate: null, timesetHasDuplicate: null,
timesetId: null timesetId: null
} }
CallForwardModule.mutations.loadTimesSucceeded(state, result); CallForwardModule.mutations.loadTimesSucceeded(state, result)
assert.equal(state.timesetTimes, result.times); assert.equal(state.timesetTimes, result.times)
}); })
})
});

@ -1,98 +1,89 @@
'use strict'; 'use strict'
import ConferenceModule from '../../src/store/conference'; import ConferenceModule from '../../src/store/conference'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Conference', function(){
describe('Conference', function () {
it('should add a participant id to the store if not already stored', () => { it('should add a participant id to the store if not already stored', () => {
let state = { const state = {
participants: [] participants: []
}; }
const participant = { const participant = {
getId: () => { getId: () => {
return '123456789'; return '123456789'
} }
}; }
ConferenceModule.mutations.participantJoined(state, participant); ConferenceModule.mutations.participantJoined(state, participant)
assert.include(state.participants, participant.getId()); assert.include(state.participants, participant.getId())
})
});
it('should not add a participant id to the store if already stored', () => { it('should not add a participant id to the store if already stored', () => {
let state = { const state = {
participants: ['123456789'] participants: ['123456789']
}; }
const participant = { const participant = {
getId: () => { getId: () => {
return '123456789'; return '123456789'
} }
}; }
ConferenceModule.mutations.participantJoined(state, participant); ConferenceModule.mutations.participantJoined(state, participant)
assert.equal(state.participants.length, 1); assert.equal(state.participants.length, 1)
})
});
it('should remove a participant id from the store', () => { it('should remove a participant id from the store', () => {
let state = { const state = {
participants: ['123456789'] participants: ['123456789']
}; }
const participant = { const participant = {
getId: () => { getId: () => {
return '123456789'; return '123456789'
} }
}; }
ConferenceModule.mutations.participantLeft(state, participant); ConferenceModule.mutations.participantLeft(state, participant)
assert.notInclude(state.participants, participant.getId()); assert.notInclude(state.participants, participant.getId())
})
});
it('should remove a participant mediastream from the store', () => { it('should remove a participant mediastream from the store', () => {
let state = { const state = {
remoteMediaStreams: { remoteMediaStreams: {
123456789: '123456789' 123456789: '123456789'
} }
}; }
const participantId = '123456789'; const participantId = '123456789'
ConferenceModule.mutations.removeRemoteMedia(state, participantId);
assert.notExists(state.remoteMediaStreams[participantId]);
}); ConferenceModule.mutations.removeRemoteMedia(state, participantId)
assert.notExists(state.remoteMediaStreams[participantId])
})
it('should store the selected remote participant as selected', () => { it('should store the selected remote participant as selected', () => {
let state = { const state = {
selectedParticipant: null selectedParticipant: null
}; }
const participantId = '123456789'; const participantId = '123456789'
ConferenceModule.mutations.setSelectedParticipant(state, participantId);
assert.equal(state.selectedParticipant, participantId);
}); ConferenceModule.mutations.setSelectedParticipant(state, participantId)
assert.equal(state.selectedParticipant, participantId)
})
it('should store the local participant as selected if current selected participant leaves', () => { it('should store the local participant as selected if current selected participant leaves', () => {
let state = { const state = {
selectedParticipant: '123456789', selectedParticipant: '123456789',
participants: [] participants: []
}; }
const participantId = '123456789'; const participantId = '123456789'
ConferenceModule.mutations.setSelectedParticipant(state, participantId);
assert.equal(state.selectedParticipant, 'local');
}); ConferenceModule.mutations.setSelectedParticipant(state, participantId)
assert.equal(state.selectedParticipant, 'local')
})
it('should reset the selected participant when conference ends', () => { it('should reset the selected participant when conference ends', () => {
let state = { const state = {
selectedParticipant: 'local', selectedParticipant: 'local',
joinState: false joinState: false
}; }
ConferenceModule.mutations.setSelectedParticipant(state);
assert.equal(state.selectedParticipant, null);
});
}); ConferenceModule.mutations.setSelectedParticipant(state)
assert.equal(state.selectedParticipant, null)
})
})

@ -1,154 +1,152 @@
'use strict'; 'use strict'
import ConversationsModule from '../../src/store/conversations/conversations'; import ConversationsModule from '../../src/store/conversations/conversations'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Conversations', function(){ describe('Conversations', function () {
it('should load next page of items', function () {
it('should load next page of items', function(){ const resultItems = []
let resultItems = []; const state = {
let state = {
items: [ items: [
{ {
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: "call", call_type: 'call',
callee: "43993006", callee: '43993006',
caller: "43993004", caller: '43993004',
currency: "", currency: '',
customer_cost: 0, customer_cost: 0,
direction: "out", direction: 'out',
duration: "0:00:00", duration: '0:00:00',
id: 85, id: 85,
rating_status: "ok", rating_status: 'ok',
start_time: "2018-06-21 14:50:00.687", start_time: '2018-06-21 14:50:00.687',
status: "noanswer", status: 'noanswer',
total_customer_cost: 0, total_customer_cost: 0,
type: "call", type: 'call',
_links: { _links: {
} }
} }
] ]
}; }
let data = { const data = {
items: [ items: [
{ {
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: "call", call_type: 'call',
callee: "43993006", callee: '43993006',
caller: "43993004", caller: '43993004',
currency: "", currency: '',
customer_cost: 0, customer_cost: 0,
direction: "out", direction: 'out',
duration: "0:00:00", duration: '0:00:00',
id: 85, id: 85,
rating_status: "ok", rating_status: 'ok',
start_time: "2018-06-21 14:50:00.687", start_time: '2018-06-21 14:50:00.687',
status: "noanswer", status: 'noanswer',
total_customer_cost: 0, total_customer_cost: 0,
type: "call", type: 'call',
_links: { _links: {
} }
} }
], ],
lastPage: 1 lastPage: 1
}; }
resultItems.push(state.items[0]); resultItems.push(state.items[0])
resultItems.push(data.items[0]); resultItems.push(data.items[0])
ConversationsModule.mutations.nextPageSucceeded(state, data); ConversationsModule.mutations.nextPageSucceeded(state, data)
assert.deepEqual(state.items, resultItems); assert.deepEqual(state.items, resultItems)
}); })
it('should load reloaded items', function(){ it('should load reloaded items', function () {
let state = { const state = {
items: [ items: [
{ {
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: "call", call_type: 'call',
callee: "43993006", callee: '43993006',
caller: "43993004", caller: '43993004',
currency: "", currency: '',
customer_cost: 0, customer_cost: 0,
direction: "out", direction: 'out',
duration: "0:00:00", duration: '0:00:00',
id: 85, id: 85,
rating_status: "ok", rating_status: 'ok',
start_time: "2018-06-21 14:50:00.687", start_time: '2018-06-21 14:50:00.687',
status: "noanswer", status: 'noanswer',
total_customer_cost: 0, total_customer_cost: 0,
type: "call", type: 'call',
_links: { _links: {
} }
} }
] ]
}; }
let data = { const data = {
items: [ items: [
{ {
call_id: "d2212956-46cc-4f9d-805d-cf2b5f572726", call_id: 'd2212956-46cc-4f9d-805d-cf2b5f572726',
call_type: "call", call_type: 'call',
callee: "43993007", callee: '43993007',
caller: "43993004", caller: '43993004',
currency: "", currency: '',
customer_cost: 0, customer_cost: 0,
direction: "out", direction: 'out',
duration: "0:00:00", duration: '0:00:00',
id: 87, id: 87,
rating_status: "ok", rating_status: 'ok',
start_time: "2018-06-21 15:02:41.762", start_time: '2018-06-21 15:02:41.762',
status: "noanswer", status: 'noanswer',
total_customer_cost: 0, total_customer_cost: 0,
type: "call", type: 'call',
_links: { _links: {
} }
}, },
{ {
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: "call", call_type: 'call',
callee: "43993006", callee: '43993006',
caller: "43993004", caller: '43993004',
currency: "", currency: '',
customer_cost: 0, customer_cost: 0,
direction: "out", direction: 'out',
duration: "0:00:00", duration: '0:00:00',
id: 85, id: 85,
rating_status: "ok", rating_status: 'ok',
start_time: "2018-06-21 14:50:00.687", start_time: '2018-06-21 14:50:00.687',
status: "noanswer", status: 'noanswer',
total_customer_cost: 0, total_customer_cost: 0,
type: "call", type: 'call',
_links: { _links: {
} }
} }
], ],
lastPage: 1 lastPage: 1
}; }
ConversationsModule.mutations.reloadItemsSucceeded(state, data); ConversationsModule.mutations.reloadItemsSucceeded(state, data)
assert.deepEqual(state.items, data.items); assert.deepEqual(state.items, data.items)
}); })
it('should load blocked numbers and mode', function(){ it('should load blocked numbers and mode', function () {
let state = { const state = {
blockedNumbersIncoming: new Set(), blockedNumbersIncoming: new Set(),
blockedModeIncoming: null, blockedModeIncoming: null,
blockedNumbersOutgoing: new Set(), blockedNumbersOutgoing: new Set(),
blockedModeOutgoing: null blockedModeOutgoing: null
}; }
let options = { const options = {
blockAnonymous: undefined, blockAnonymous: undefined,
enabled: undefined, enabled: undefined,
list: [ list: [
"123456", '123456',
"555555" '555555'
] ]
}; }
let listSet = new Set(["123456", "555555"]); const listSet = new Set(['123456', '555555'])
ConversationsModule.mutations.blockedIncomingSucceeded(state, options); ConversationsModule.mutations.blockedIncomingSucceeded(state, options)
ConversationsModule.mutations.blockedOutgoingSucceeded(state, options); ConversationsModule.mutations.blockedOutgoingSucceeded(state, options)
assert.deepEqual(state.blockedNumbersIncoming, listSet); assert.deepEqual(state.blockedNumbersIncoming, listSet)
assert.equal(state.blockedModeIncoming, 'blacklist'); assert.equal(state.blockedModeIncoming, 'blacklist')
assert.deepEqual(state.blockedNumbersOutgoing, listSet); assert.deepEqual(state.blockedNumbersOutgoing, listSet)
assert.equal(state.blockedModeOutgoing, 'blacklist'); assert.equal(state.blockedModeOutgoing, 'blacklist')
}); })
})
});

@ -1,13 +1,12 @@
'use strict'; 'use strict'
import PbxConfig from '../../src/store/pbx-config'; import PbxConfig from '../../src/store/pbx-config'
import { assert } from 'chai'; import { assert } from 'chai'
describe('PBX Configuration Store', () => { describe('PBX Configuration Store', () => {
it('should list all PBX Groups', () => { it('should list all PBX Groups', () => {
let state = {}; const state = {}
let data = { const data = {
pilot: {}, pilot: {},
seats: { seats: {
2: { 2: {
@ -35,16 +34,16 @@ describe('PBX Configuration Store', () => {
id: 7 id: 7
} }
] ]
}; }
PbxConfig.mutations.listSucceeded(state, data); PbxConfig.mutations.listSucceeded(state, data)
assert.equal(state.seats, data.seats); assert.equal(state.seats, data.seats)
assert.equal(state.groups, data.groups); assert.equal(state.groups, data.groups)
assert.deepEqual(state.numbers, data.numbers); assert.deepEqual(state.numbers, data.numbers)
}); })
it('should list all Sound Sets', () => { it('should list all Sound Sets', () => {
let state = {}; const state = {}
let data = { const data = {
items: [ items: [
{ {
contract_defaults: true, contract_defaults: true,
@ -63,10 +62,9 @@ describe('PBX Configuration Store', () => {
name: 'Set 2' name: 'Set 2'
} }
] ]
}; }
PbxConfig.mutations.listSoundSetsSucceeded(state, data); PbxConfig.mutations.listSoundSetsSucceeded(state, data)
assert.equal(state.soundSets[15], data.items[0]); assert.equal(state.soundSets[15], data.items[0])
assert.equal(state.soundSets[17], data.items[1]); assert.equal(state.soundSets[17], data.items[1])
}); })
})
});

@ -1,27 +1,25 @@
'use strict'; 'use strict'
import SpeedDialModule from '../../src/store/speed-dial'; import SpeedDialModule from '../../src/store/speed-dial'
import { assert } from 'chai'; import { assert } from 'chai'
describe('SpeedDial', function(){ describe('SpeedDial', function () {
it('should load all assigned speed dial slots', function () {
it('should load all assigned speed dial slots', function(){ const state = {
let state = {
assignedSlots: [] assignedSlots: []
}; }
let data = [ const data = [
{ {
destination: "sip:111111@192.168.178.23", destination: 'sip:111111@192.168.178.23',
slot: "*1" slot: '*1'
}, },
{ {
destination: "sip:333333@192.168.178.23", destination: 'sip:333333@192.168.178.23',
slot: "*3" slot: '*3'
} }
]; ]
SpeedDialModule.mutations.speedDialSucceeded(state, data); SpeedDialModule.mutations.speedDialSucceeded(state, data)
assert.deepEqual(state.assignedSlots, data); assert.deepEqual(state.assignedSlots, data)
}); })
})
});

@ -1,17 +1,16 @@
'use strict'; 'use strict'
import UserModule from '../../src/store/user'; import UserModule from '../../src/store/user'
import { assert } from 'chai'; import { assert } from 'chai'
describe('UserModule', ()=>{ describe('UserModule', () => {
it('should login', () => {
it('should login', ()=>{ var state = {}
var state = {};
UserModule.mutations.loginSucceeded(state, { UserModule.mutations.loginSucceeded(state, {
jwt: 'abc123', jwt: 'abc123',
subscriberId: 123 subscriberId: 123
}); })
assert.equal(state.jwt, 'abc123'); assert.equal(state.jwt, 'abc123')
assert.equal(state.subscriberId, '123'); assert.equal(state.subscriberId, '123')
}); })
}); })

@ -1,107 +1,104 @@
'use strict'; 'use strict'
import VoiceboxModule from '../../src/store/voicebox'; import VoiceboxModule from '../../src/store/voicebox'
import localeEn from 'src/i18n/en.json' import localeEn from 'src/i18n/en.json'
import { i18n } from '../../src/i18n'; import { i18n } from '../../src/i18n'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Voicebox', function(){ describe('Voicebox', function () {
it('should load all voicebox settings into store', function () {
it('should load all voicebox settings into store', function(){ const state = {
let state = {
voiceboxSettingDelete: false, voiceboxSettingDelete: false,
voiceboxSettingAttach: false, voiceboxSettingAttach: false,
voiceboxSettingPin: '', voiceboxSettingPin: '',
voiceboxSettingEmail: '', voiceboxSettingEmail: ''
}; }
let settings = { const settings = {
attach: true, attach: true,
delete: false, delete: false,
email: '', email: '',
id: 123, id: 123,
pin: 1234, pin: 1234,
sms_number: '' sms_number: ''
}; }
VoiceboxModule.mutations.loadSettingsSucceeded(state, settings); VoiceboxModule.mutations.loadSettingsSucceeded(state, settings)
assert.equal(state.voiceboxSettingDelete, settings.delete); assert.equal(state.voiceboxSettingDelete, settings.delete)
assert.equal(state.voiceboxSettingAttach, settings.attach); assert.equal(state.voiceboxSettingAttach, settings.attach)
assert.equal(state.voiceboxSettingEmail, settings.email); assert.equal(state.voiceboxSettingEmail, settings.email)
assert.equal(state.voiceboxSettingPin, settings.pin); assert.equal(state.voiceboxSettingPin, settings.pin)
})
});
it('should load all busy greeting id into store', function(){ it('should load all busy greeting id into store', function () {
let state = { const state = {
busyGreetingId: null busyGreetingId: null
}; }
let greetings = [ const greetings = [
{ {
id: 1 id: 1
} }
]; ]
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings); VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings)
assert.deepEqual(state.busyGreetingId, greetings[0].id); assert.deepEqual(state.busyGreetingId, greetings[0].id)
}); })
it('should load busy greeting id into store', function(){ it('should load busy greeting id into store', function () {
let state = { const state = {
busyGreetingId: null busyGreetingId: null
}; }
let greetings = [ const greetings = [
{ {
id: 1 id: 1
} }
]; ]
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings); VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings)
assert.deepEqual(state.busyGreetingId, greetings[0].id); assert.deepEqual(state.busyGreetingId, greetings[0].id)
}); })
it('should load unavailable greeting id into store', function(){ it('should load unavailable greeting id into store', function () {
let state = { const state = {
unavailGreetingId: null unavailGreetingId: null
}; }
let greetings = [ const greetings = [
{ {
id: 1 id: 1
} }
]; ]
VoiceboxModule.mutations.loadUnavailGreetingSucceeded(state, greetings); VoiceboxModule.mutations.loadUnavailGreetingSucceeded(state, greetings)
assert.deepEqual(state.unavailGreetingId, greetings[0].id); assert.deepEqual(state.unavailGreetingId, greetings[0].id)
}); })
it('should load busy greeting url into store', function(){ it('should load busy greeting url into store', function () {
let state = { const state = {
playBusyGreetingUrl: null playBusyGreetingUrl: null
}; }
let url = "blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821"; const url = 'blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821'
VoiceboxModule.mutations.playBusyGreetingSucceeded(state, url); VoiceboxModule.mutations.playBusyGreetingSucceeded(state, url)
assert.deepEqual(state.playBusyGreetingUrl, url); assert.deepEqual(state.playBusyGreetingUrl, url)
}); })
it('should load unavailable greeting id into store', function(){ it('should load unavailable greeting id into store', function () {
let state = { const state = {
playUnavailGreetingUrl: null playUnavailGreetingUrl: null
}; }
let url = "blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821"; const url = 'blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821'
VoiceboxModule.mutations.playUnavailGreetingSucceeded(state, url); VoiceboxModule.mutations.playUnavailGreetingSucceeded(state, url)
assert.deepEqual(state.playUnavailGreetingUrl, url); assert.deepEqual(state.playUnavailGreetingUrl, url)
}); })
it('should get right label for busy greeting to indicate if it\'s custom or default', function(){ it('should get right label for busy greeting to indicate if it\'s custom or default', function () {
let state = { const state = {
busyGreetingId: null busyGreetingId: null
}; }
let getterObject = VoiceboxModule.getters.busyGreetingLabel(state); const getterObject = VoiceboxModule.getters.busyGreetingLabel(state)
assert.equal(getterObject, i18n.t('voicebox.label.defaultSoundActive')); assert.equal(getterObject, i18n.t('voicebox.label.defaultSoundActive'))
}); })
it('should get right label for unavailable greeting to indicate if it\'s custom or default', function(){ it('should get right label for unavailable greeting to indicate if it\'s custom or default', function () {
let state = { const state = {
unavailGreetingId: 1 unavailGreetingId: 1
}; }
let getterObject = VoiceboxModule.getters.unavailGreetingLabel(state); const getterObject = VoiceboxModule.getters.unavailGreetingLabel(state)
assert.equal(getterObject, i18n.t('voicebox.label.customSoundActive')); assert.equal(getterObject, i18n.t('voicebox.label.customSoundActive'))
}); })
})
});

@ -1,74 +1,72 @@
'use strict'; 'use strict'
import { assert } from 'chai'; import { assert } from 'chai'
import { isYesterday, isToday, isWithinLastWeek } from '../../src/helpers/date-helper' import { isYesterday, isToday, isWithinLastWeek } from '../../src/helpers/date-helper'
describe('Date helper', function() { describe('Date helper', function () {
it('should check whether a given date is yesterday or not', function () {
const today = new Date('2000-01-01 00:00:00')
const beforeYesterday = new Date('1999-12-30 00:00:00')
const tomorrow = new Date('2000-01-02 00:00:00')
it('should check whether a given date is yesterday or not', function() { const yesterday1 = new Date('1999-12-31 00:00:00')
let today = new Date('2000-01-01 00:00:00'); const yesterday2 = new Date('1999-12-31 14:00:00')
let beforeYesterday = new Date('1999-12-30 00:00:00'); const yesterday3 = new Date('1999-12-31 23:59:59')
let tomorrow = new Date('2000-01-02 00:00:00');
let yesterday1 = new Date('1999-12-31 00:00:00'); assert.isTrue(isYesterday(yesterday1, today))
let yesterday2 = new Date('1999-12-31 14:00:00'); assert.isTrue(isYesterday(yesterday2, today))
let yesterday3 = new Date('1999-12-31 23:59:59'); assert.isTrue(isYesterday(yesterday3, today))
assert.isTrue(isYesterday(yesterday1, today)); assert.isFalse(isYesterday(beforeYesterday, today))
assert.isTrue(isYesterday(yesterday2, today)); assert.isFalse(isYesterday(today, today))
assert.isTrue(isYesterday(yesterday3, today)); assert.isFalse(isYesterday(tomorrow, today))
})
assert.isFalse(isYesterday(beforeYesterday, today)); it('should check whether a given date is today or not', function () {
assert.isFalse(isYesterday(today, today)); const today = new Date('2000-01-01 00:00:00')
assert.isFalse(isYesterday(tomorrow, today)); const yesterday = new Date('1999-12-31 00:00:00')
}); const beforeYesterday = new Date('1999-12-30 00:00:00')
const tomorrow = new Date('2000-01-02 00:00:00')
const afterTomorrow = new Date('2000-01-03 00:00:00')
it('should check whether a given date is today or not', function() { const today1 = new Date('2000-01-01 00:00:00')
let today = new Date('2000-01-01 00:00:00'); const today2 = new Date('2000-01-01 14:00:00')
let yesterday = new Date('1999-12-31 00:00:00'); const today3 = new Date('2000-01-01 23:59:59')
let beforeYesterday = new Date('1999-12-30 00:00:00');
let tomorrow = new Date('2000-01-02 00:00:00');
let afterTomorrow = new Date('2000-01-03 00:00:00');
let today1 = new Date('2000-01-01 00:00:00'); assert.isTrue(isToday(today, today))
let today2 = new Date('2000-01-01 14:00:00'); assert.isTrue(isToday(today1, today))
let today3 = new Date('2000-01-01 23:59:59'); assert.isTrue(isToday(today2, today))
assert.isTrue(isToday(today3, today))
assert.isTrue(isToday(today, today)); assert.isFalse(isToday(beforeYesterday, today))
assert.isTrue(isToday(today1, today)); assert.isFalse(isToday(yesterday, today))
assert.isTrue(isToday(today2, today)); assert.isFalse(isToday(tomorrow, today))
assert.isTrue(isToday(today3, today)); assert.isFalse(isToday(afterTomorrow, today))
})
assert.isFalse(isToday(beforeYesterday, today)); it('should check whether a given date is within last week or not', function () {
assert.isFalse(isToday(yesterday, today)); const today = new Date('2000-01-01 00:00:00')
assert.isFalse(isToday(tomorrow, today)); const validDay1 = new Date('1999-12-31 00:00:00')
assert.isFalse(isToday(afterTomorrow, today)); const validDay2 = new Date('1999-12-30 00:00:00')
}); const validDay3 = new Date('1999-12-29 00:00:00')
const validDay4 = new Date('1999-12-28 00:00:00')
const validDay5 = new Date('1999-12-27 00:00:00')
const validDay6 = new Date('1999-12-26 00:00:00')
it('should check whether a given date is within last week or not', function(){ const invalidDay1 = new Date('1999-12-25 00:00:00')
const invalidDay2 = new Date('1999-12-24 00:00:00')
const invalidDay3 = new Date('1999-12-23 00:00:00')
let today = new Date('2000-01-01 00:00:00'); assert.isTrue(isWithinLastWeek(validDay1, today))
let validDay1 = new Date('1999-12-31 00:00:00'); assert.isTrue(isWithinLastWeek(validDay2, today))
let validDay2 = new Date('1999-12-30 00:00:00'); assert.isTrue(isWithinLastWeek(validDay3, today))
let validDay3 = new Date('1999-12-29 00:00:00'); assert.isTrue(isWithinLastWeek(validDay4, today))
let validDay4 = new Date('1999-12-28 00:00:00'); assert.isTrue(isWithinLastWeek(validDay5, today))
let validDay5 = new Date('1999-12-27 00:00:00'); assert.isTrue(isWithinLastWeek(validDay6, today))
let validDay6 = new Date('1999-12-26 00:00:00');
let invalidDay1 = new Date('1999-12-25 00:00:00'); assert.isFalse(isWithinLastWeek(today, today))
let invalidDay2 = new Date('1999-12-24 00:00:00'); assert.isFalse(isWithinLastWeek(invalidDay1, today))
let invalidDay3 = new Date('1999-12-23 00:00:00'); assert.isFalse(isWithinLastWeek(invalidDay2, today))
assert.isFalse(isWithinLastWeek(invalidDay3, today))
assert.isTrue(isWithinLastWeek(validDay1, today)); })
assert.isTrue(isWithinLastWeek(validDay2, today)); })
assert.isTrue(isWithinLastWeek(validDay3, today));
assert.isTrue(isWithinLastWeek(validDay4, today));
assert.isTrue(isWithinLastWeek(validDay5, today));
assert.isTrue(isWithinLastWeek(validDay6, today));
assert.isFalse(isWithinLastWeek(today, today));
assert.isFalse(isWithinLastWeek(invalidDay1, today));
assert.isFalse(isWithinLastWeek(invalidDay2, today));
assert.isFalse(isWithinLastWeek(invalidDay3, today));
});
});

@ -1,19 +1,18 @@
'use strict'; 'use strict'
import { assert } from 'chai'; import { assert } from 'chai'
import numberFormat from '../../src/filters/number-format'; import numberFormat, { normalizeDestination } from '../../src/filters/number-format'
import { normalizeDestination } from '../../src/filters/number-format';
const numbers = { const numbers = {
valid1: '43993004', valid1: '43993004',
invalid1: '43993004+', invalid1: '43993004+',
invalid2: 'a43993004', invalid2: 'a43993004'
}; }
const sipUris = { const sipUris = {
valid1: 'sip:43993004@sipwise.com', valid1: 'sip:43993004@sipwise.com',
invalid1: 'sip:a43993004@sipwise.com' invalid1: 'sip:a43993004@sipwise.com'
}; }
const destinations = { const destinations = {
voiceMail: 'sip:vmu@voicebox.local', voiceMail: 'sip:vmu@voicebox.local',
@ -23,22 +22,21 @@ const destinations = {
customHours: 'sip:custom-hours@app.local', customHours: 'sip:custom-hours@app.local',
conference: 'sip:@conference.local', conference: 'sip:@conference.local',
number: 'sip:43993004@sipwise.com' number: 'sip:43993004@sipwise.com'
}; }
describe('NumberFormatFilter', function() { describe('NumberFormatFilter', function () {
it('should format a number or sip uri', function () {
assert.equal(numberFormat(sipUris.valid1), numbers.valid1)
assert.equal(numberFormat(sipUris.invalid1), numbers.invalid2)
})
it('should format a number or sip uri', function(){ it('should format a call forward destination', function () {
assert.equal(numberFormat(sipUris.valid1), numbers.valid1); assert.equal(normalizeDestination(destinations.voiceMail), 'Voicebox')
assert.equal(numberFormat(sipUris.invalid1), numbers.invalid2); assert.equal(normalizeDestination(destinations.fax2Mail), 'Fax2Mail')
}); assert.equal(normalizeDestination(destinations.managerSecretary), 'Manager Secretary')
assert.equal(normalizeDestination(destinations.app), 'App')
it('should format a call forward destination', function(){ assert.equal(normalizeDestination(destinations.customHours), 'Custom Announcement')
assert.equal(normalizeDestination(destinations.voiceMail), 'Voicebox'); assert.equal(normalizeDestination(destinations.conference), 'Conference')
assert.equal(normalizeDestination(destinations.fax2Mail), 'Fax2Mail'); assert.equal(normalizeDestination(destinations.number), numbers.valid1)
assert.equal(normalizeDestination(destinations.managerSecretary), 'Manager Secretary'); })
assert.equal(normalizeDestination(destinations.app), 'App'); })
assert.equal(normalizeDestination(destinations.customHours), 'Custom Announcement');
assert.equal(normalizeDestination(destinations.conference), 'Conference');
assert.equal(normalizeDestination(destinations.number), numbers.valid1);
});
});

@ -1,61 +1,57 @@
'use strict'; 'use strict'
import { assert } from 'chai'; import { assert } from 'chai'
import { import {
userInfo, userInfo,
customMacAddress customMacAddress
} from '../../src/helpers/validation' } from '../../src/helpers/validation'
describe('Userinfo validation helper', function() { describe('Userinfo validation helper', function () {
it('should validate userinfo consisting of phone number and country code', function () {
it('should validate userinfo consisting of phone number and country code', function() { const input = '+439988776655'
let input = "+439988776655"; assert.isTrue(userInfo(input))
assert.isTrue(userInfo(input)); })
});
it('should validate userinfo with parameter', function () {
it('should validate userinfo with parameter', function() { const input = '+358-555-1234567;postd=pp22'
let input = "+358-555-1234567;postd=pp22"; assert.isTrue(userInfo(input))
assert.isTrue(userInfo(input)); })
});
it('should validate userinfo consisting of subscriber username', function () {
it('should validate userinfo consisting of subscriber username', function() { const input = 'alice'
let input = "alice"; assert.isTrue(userInfo(input))
assert.isTrue(userInfo(input)); })
});
it('should not validate invalid userinfo characters', function () {
it('should not validate invalid userinfo characters', function() { const input = 'al)<e'
let input = "al)<e"; assert.isFalse(userInfo(input))
assert.isFalse(userInfo(input)); })
}); })
}); describe('Custom mac address validation helper', function () {
it('should validate mac address separated by colon', function () {
describe('Custom mac address validation helper', function() { const input = '13:14:5f:cD:42:5f'
assert.isTrue(customMacAddress(input))
it('should validate mac address separated by colon', function() { })
let input = "13:14:5f:cD:42:5f";
assert.isTrue(customMacAddress(input)); it('should validate mac address separated by hyphen', function () {
}); const input = '13-14-5f-cD-42-5f'
assert.isTrue(customMacAddress(input))
it('should validate mac address separated by hyphen', function() { })
let input = "13-14-5f-cD-42-5f";
assert.isTrue(customMacAddress(input)); it('should validate mac address without separator', function () {
}); const input = '13145fcD425f'
assert.isTrue(customMacAddress(input))
it('should validate mac address without separator', function() { })
let input = "13145fcD425f";
assert.isTrue(customMacAddress(input)); it('should not validate mac address with mixed separator', function () {
}); const input = '13:14:5f:cD:42-5f'
assert.isFalse(customMacAddress(input))
it('should not validate mac address with mixed separator', function() { })
let input = "13:14:5f:cD:42-5f";
assert.isFalse(customMacAddress(input)); it('should not validate mac address when invalid', function () {
}); const input = 'k183p1r23411'
assert.isFalse(customMacAddress(input))
it('should not validate mac address when invalid', function() { })
let input = "k183p1r23411"; })
assert.isFalse(customMacAddress(input));
});
});

@ -1,5 +1,5 @@
<template> <template>
<div></div> <div />
</template> </template>
<script> <script>

@ -1,9 +1,14 @@
<template> <template>
<div> <div>
<p class="textContent">{{ input }}</p> <p class="textContent">
{{ input }}
</p>
<span>{{ counter }}</span> <span>{{ counter }}</span>
<q-btn id="mybutton" @click="increment()"></q-btn> <q-btn
</div> id="mybutton"
@click="increment()"
/>
</div>
</template> </template>
<script> <script>

@ -47,6 +47,6 @@ Object.keys(originalExpect).forEach(key => (global.expect[key] = originalExpect[
*/ */
// do this to make sure we don't get multiple hits from both webpacks when running SSR // do this to make sure we don't get multiple hits from both webpacks when running SSR
setTimeout(()=>{ setTimeout(() => {
// do nothing // do nothing
}, 1) }, 1)

Loading…
Cancel
Save