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

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

@ -1,5 +1,5 @@
const fs = require('fs-extra')
let extend = undefined
let extend
/**
* The .babelrc file has been created to assist Jest for transpiling.
@ -7,12 +7,12 @@ let extend = undefined
*/
if (fs.existsSync('./.babelrc')) {
extend = './.babelrc'
extend = './.babelrc'
}
module.exports = {
presets: [
'@quasar/babel-preset-app'
],
extends: extend
presets: [
'@quasar/babel-preset-app'
],
extends: extend
}

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

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

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

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

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

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

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

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

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

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

@ -1,310 +1,309 @@
'use strict';
'use strict'
import Vue from 'vue';
import VueResource from 'vue-resource';
import Vue from 'vue'
import VueResource from 'vue-resource'
import {
enableIncomingCallBlocking,
disableIncomingCallBlocking,
getIncomingCallBlocking,
addNumberToIncomingList,
editNumberFromIncomingList,
removeNumberFromIncomingList,
enableOutgoingCallBlocking,
disableOutgoingCallBlocking,
getOutgoingCallBlocking,
addNumberToOutgoingList,
editNumberFromOutgoingList,
removeNumberFromOutgoingList
} from '../../src/api/call-blocking';
import { assert } from 'chai';
enableIncomingCallBlocking,
disableIncomingCallBlocking,
getIncomingCallBlocking,
addNumberToIncomingList,
editNumberFromIncomingList,
removeNumberFromIncomingList,
enableOutgoingCallBlocking,
disableOutgoingCallBlocking,
getOutgoingCallBlocking,
addNumberToOutgoingList,
editNumberFromOutgoingList,
removeNumberFromOutgoingList
} from '../../src/api/call-blocking'
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(){
Vue.http.interceptors = [];
});
describe('Incoming', function () {
it('should enable call blocking for incoming calls', function (done) {
Vue.http.interceptors.unshift((request, next) => {
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('', {
status: 204
}))
})
enableIncomingCallBlocking(subscriberId).then(() => {
done()
}).catch((err) => {
done(err)
})
})
describe('Incoming', function(){
it('should enable call blocking for incoming calls', function(done) {
Vue.http.interceptors.unshift((request, next)=>{
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('', {
status: 204
}));
});
enableIncomingCallBlocking(subscriberId).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should disable call blocking for incoming calls', function (done) {
Vue.http.interceptors.unshift((request, next) => {
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, false)
next(request.respondWith('', {
status: 204
}))
})
disableIncomingCallBlocking(subscriberId).then(() => {
done()
}).catch((err) => {
done(err)
})
})
it('should disable call blocking for incoming calls', function(done) {
Vue.http.interceptors.unshift((request, next)=>{
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, false);
next(request.respondWith('', {
status: 204
}));
});
disableIncomingCallBlocking(subscriberId).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should get all data regarding incoming call blocking', function (done) {
var list = [
'0123456789',
'0987654321'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
next(request.respondWith(JSON.stringify({
block_in_list: list,
block_in_mode: true
}), {
status: 200
}))
})
getIncomingCallBlocking(subscriberId).then((result) => {
assert.deepEqual(result.list, list)
assert.equal(result.enabled, true)
done()
}).catch((err) => {
done(err)
})
})
it('should get all data regarding incoming call blocking', function(done){
var list = [
"0123456789",
"0987654321"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
next(request.respondWith(JSON.stringify({
"block_in_list" : list,
"block_in_mode" : true
}), {
status: 200
}));
});
getIncomingCallBlocking(subscriberId).then((result)=>{
assert.deepEqual(result.list, list);
assert.equal(result.enabled, true);
done();
}).catch((err)=>{
done(err);
});
});
it('should add a new number to incoming call blocking list', function (done) {
var number = '0987654321'
var list = [
'0123456789'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({
block_in_list: list
}), {
status: 200
}))
} else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [].concat([number], list))
next(request.respondWith('', {
status: 200
}))
}
})
addNumberToIncomingList(subscriberId, number).then((result) => {
done()
}).catch((err) => {
done(err)
})
})
it('should add a new number to incoming call blocking list', function(done){
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_in_list" : list
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [].concat([number], list));
next(request.respondWith('', {
status: 200
}));
}
});
addNumberToIncomingList(subscriberId, number).then((result)=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should edit a number from incoming call blocking list', function (done) {
var number = '0987654321'
var list = [
'0123456789'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({
block_in_list: list
}), {
status: 200
}))
} else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [number])
next(request.respondWith('', {
status: 200
}))
}
})
editNumberFromIncomingList(subscriberId, 0, number).then((result) => {
done()
}).catch((err) => {
done(err)
})
})
it('should edit a number from incoming call blocking list', function(done){
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_in_list" : list
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [number]);
next(request.respondWith('', {
status: 200
}));
}
});
editNumberFromIncomingList(subscriberId, 0, number).then((result)=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should remove a number from incoming call blocking list', function (done) {
var number = '0987654321'
var list = [
'0123456789'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({
block_in_list: [].concat([number]).concat(list)
}), {
status: 200
}))
} else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, list)
next(request.respondWith('', {
status: 200
}))
}
})
removeNumberFromIncomingList(subscriberId, 0, number).then((result) => {
done()
}).catch((err) => {
done(err)
})
})
})
it('should remove a number from incoming call blocking list', function(done){
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_in_list" : [].concat([number]).concat(list)
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, list);
next(request.respondWith('', {
status: 200
}));
}
});
removeNumberFromIncomingList(subscriberId, 0, number).then((result)=>{
done();
}).catch((err)=>{
done(err);
});
});
});
describe('Outgoing', function () {
it('should enable call blocking for outgoing calls', function (done) {
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].path, '/block_out_mode')
assert.equal(request.body[0].value, true)
next(request.respondWith('', {
status: 204
}))
})
enableOutgoingCallBlocking(subscriberId).then(() => {
done()
}).catch((err) => {
done(err)
})
})
describe('Outgoing', function(){
it('should enable call blocking for outgoing calls', function(done) {
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
assert.equal(request.body[0].op, 'replace');
assert.equal(request.body[0].path, '/block_out_mode');
assert.equal(request.body[0].value, true);
next(request.respondWith('', {
status: 204
}));
});
enableOutgoingCallBlocking(subscriberId).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should disable call blocking for outgoing calls', function (done) {
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].path, '/block_out_mode')
assert.equal(request.body[0].value, false)
next(request.respondWith('', {
status: 204
}))
})
disableOutgoingCallBlocking(subscriberId).then(() => {
done()
}).catch((err) => {
done(err)
})
})
it('should disable call blocking for outgoing calls', function(done) {
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
assert.equal(request.body[0].op, 'replace');
assert.equal(request.body[0].path, '/block_out_mode');
assert.equal(request.body[0].value, false);
next(request.respondWith('', {
status: 204
}));
});
disableOutgoingCallBlocking(subscriberId).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should get all data regarding outgoing call blocking', function (done) {
var list = [
'0123456789',
'0987654321'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
next(request.respondWith(JSON.stringify({
block_out_list: list,
block_out_mode: true
}), {
status: 200
}))
})
getOutgoingCallBlocking(subscriberId).then((result) => {
assert.deepEqual(result.list, list)
assert.equal(result.enabled, true)
done()
}).catch((err) => {
done(err)
})
})
it('should get all data regarding outgoing call blocking', function(done){
var list = [
"0123456789",
"0987654321"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
next(request.respondWith(JSON.stringify({
"block_out_list" : list,
"block_out_mode" : true
}), {
status: 200
}));
});
getOutgoingCallBlocking(subscriberId).then((result)=>{
assert.deepEqual(result.list, list);
assert.equal(result.enabled, true);
done();
}).catch((err)=>{
done(err);
});
});
it('should add a new number to outgoing call blocking list', function (done) {
var number = '0987654321'
var list = [
'0123456789'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({
block_out_list: list
}), {
status: 200
}))
} else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [].concat([number], list))
next(request.respondWith('', {
status: 200
}))
}
})
addNumberToOutgoingList(subscriberId, number).then((result) => {
done()
}).catch((err) => {
done(err)
})
})
it('should add a new number to outgoing call blocking list', function(done){
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_out_list" : list
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [].concat([number], list));
next(request.respondWith('', {
status: 200
}));
}
});
addNumberToOutgoingList(subscriberId, number).then((result)=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should edit a number from outgoing call blocking list', function (done) {
var number = '0987654321'
var list = [
'0123456789'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({
block_out_list: list
}), {
status: 200
}))
} else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [number])
next(request.respondWith('', {
status: 200
}))
}
})
editNumberFromOutgoingList(subscriberId, 0, number).then((result) => {
done()
}).catch((err) => {
done(err)
})
})
it('should edit a number from outgoing call blocking list', function(done){
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_out_list" : list
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [number]);
next(request.respondWith('', {
status: 200
}));
}
});
editNumberFromOutgoingList(subscriberId, 0, number).then((result)=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should remove a number from outgoing call blocking list', function(done){
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_out_list" : [].concat([number]).concat(list)
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, list);
next(request.respondWith('', {
status: 200
}));
}
});
removeNumberFromOutgoingList(subscriberId, 0).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
});
});
it('should remove a number from outgoing call blocking list', function (done) {
var number = '0987654321'
var list = [
'0123456789'
]
Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({
block_out_list: [].concat([number]).concat(list)
}), {
status: 200
}))
} else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, list)
next(request.respondWith('', {
status: 200
}))
}
})
removeNumberFromOutgoingList(subscriberId, 0).then(() => {
done()
}).catch((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 VueResource from 'vue-resource';
import Vue from 'vue'
import VueResource from 'vue-resource'
import crypto from 'crypto-browserify'
import { getConversations } from '../../src/api/conversations';
import { assert } from 'chai';
import { getConversations } from '../../src/api/conversations'
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 = [{
_links: {
collection: {
href: '/api/conversations/'
},
curies: {
href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
name: 'ngcp',
templated: true
},
'ngcp:conversations': {
href: '/api/conversations/1?type=voicemail'
},
'ngcp:voicemailrecordings': {
href: '/api/voicemailrecordings/1'
},
'ngcp:voicemails': {
href: '/api/voicemails/1'
},
profile: {
href: 'http://purl.org/sipwise/ngcp-api/'
},
self: {
href: '/api/conversations/1?type=voicemail'
}
},
call_id: 'kp55kEGtNp',
callee: '43993006',
caller: '43993006',
context: 'voicemailcaller_unavail',
direction: 'in',
duration: '15',
filename: 'voicemail-0.wav',
folder: 'Old',
id: 1,
start_time: '2017-12-07 16:22:04',
type: 'voicemail',
voicemail_subscriber_id: 235
}]
it('should get all data regarding conversations', function(done){
const data = {
_embedded: {
'ngcp:conversations': innerData
},
total_count: 1
}
let innerData = [{
"_links" : {
"collection": {
"href": "/api/conversations/"
},
"curies": {
"href": "http://purl.org/sipwise/ngcp-api/#rel-{rel}",
"name": "ngcp",
"templated": true
},
"ngcp:conversations": {
"href": "/api/conversations/1?type=voicemail"
},
"ngcp:voicemailrecordings": {
"href": "/api/voicemailrecordings/1"
},
"ngcp:voicemails": {
"href": "/api/voicemails/1"
},
"profile": {
"href": "http://purl.org/sipwise/ngcp-api/"
},
"self": {
"href": "/api/conversations/1?type=voicemail"
}
},
"call_id": "kp55kEGtNp",
"callee": "43993006",
"caller": "43993006",
"context": "voicemailcaller_unavail",
"direction": "in",
"duration": "15",
"filename": "voicemail-0.wav",
"folder": "Old",
"id": 1,
"start_time": "2017-12-07 16:22:04",
"type": "voicemail",
"voicemail_subscriber_id": 235
}];
const innerDataTransformed = {
items: [{
call_id: 'kp55kEGtNp',
callee: '43993006',
caller: '43993006',
context: 'voicemailcaller_unavail',
direction: 'in',
duration: '15',
filename: 'voicemail-0.wav',
folder: 'Old',
id: 1,
start_time: '2017-12-07 16:22:04',
type: 'voicemail',
voicemail_subscriber_id: 235
}],
lastPage: 1
}
let data = {
"_embedded": {
"ngcp:conversations": innerData
},
total_count: 1
};
let innerDataTransformed = {
items: [{
"call_id": "kp55kEGtNp",
"callee": "43993006",
"caller": "43993006",
"context": "voicemailcaller_unavail",
"direction": "in",
"duration": "15",
"filename": "voicemail-0.wav",
"folder": "Old",
"id": 1,
"start_time": "2017-12-07 16:22:04",
"type": "voicemail",
"voicemail_subscriber_id": 235
}],
lastPage: 1
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getConversations(subscriberId).then((result)=>{
assert.deepEqual(result, innerDataTransformed);
done();
}).catch((err)=>{
done(err);
});
});
});
Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
status: 200
}))
})
getConversations(subscriberId).then((result) => {
assert.deepEqual(result, innerDataTransformed)
done()
}).catch((err) => {
done(err)
})
})
})

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

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

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

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

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

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

@ -1,98 +1,89 @@
'use strict';
import ConferenceModule from '../../src/store/conference';
import { assert } from 'chai';
describe('Conference', function(){
it('should add a participant id to the store if not already stored', () => {
let state = {
participants: []
};
const participant = {
getId: () => {
return '123456789';
}
};
ConferenceModule.mutations.participantJoined(state, participant);
assert.include(state.participants, participant.getId());
});
it('should not add a participant id to the store if already stored', () => {
let state = {
participants: ['123456789']
};
const participant = {
getId: () => {
return '123456789';
}
};
ConferenceModule.mutations.participantJoined(state, participant);
assert.equal(state.participants.length, 1);
});
it('should remove a participant id from the store', () => {
let state = {
participants: ['123456789']
};
const participant = {
getId: () => {
return '123456789';
}
};
ConferenceModule.mutations.participantLeft(state, participant);
assert.notInclude(state.participants, participant.getId());
});
it('should remove a participant mediastream from the store', () => {
let state = {
remoteMediaStreams: {
123456789: '123456789'
}
};
const participantId = '123456789';
ConferenceModule.mutations.removeRemoteMedia(state, participantId);
assert.notExists(state.remoteMediaStreams[participantId]);
});
it('should store the selected remote participant as selected', () => {
let state = {
selectedParticipant: null
};
const participantId = '123456789';
ConferenceModule.mutations.setSelectedParticipant(state, participantId);
assert.equal(state.selectedParticipant, participantId);
});
it('should store the local participant as selected if current selected participant leaves', () => {
let state = {
selectedParticipant: '123456789',
participants: []
};
const participantId = '123456789';
ConferenceModule.mutations.setSelectedParticipant(state, participantId);
assert.equal(state.selectedParticipant, 'local');
});
it('should reset the selected participant when conference ends', () => {
let state = {
selectedParticipant: 'local',
joinState: false
};
ConferenceModule.mutations.setSelectedParticipant(state);
assert.equal(state.selectedParticipant, null);
});
});
'use strict'
import ConferenceModule from '../../src/store/conference'
import { assert } from 'chai'
describe('Conference', function () {
it('should add a participant id to the store if not already stored', () => {
const state = {
participants: []
}
const participant = {
getId: () => {
return '123456789'
}
}
ConferenceModule.mutations.participantJoined(state, participant)
assert.include(state.participants, participant.getId())
})
it('should not add a participant id to the store if already stored', () => {
const state = {
participants: ['123456789']
}
const participant = {
getId: () => {
return '123456789'
}
}
ConferenceModule.mutations.participantJoined(state, participant)
assert.equal(state.participants.length, 1)
})
it('should remove a participant id from the store', () => {
const state = {
participants: ['123456789']
}
const participant = {
getId: () => {
return '123456789'
}
}
ConferenceModule.mutations.participantLeft(state, participant)
assert.notInclude(state.participants, participant.getId())
})
it('should remove a participant mediastream from the store', () => {
const state = {
remoteMediaStreams: {
123456789: '123456789'
}
}
const participantId = '123456789'
ConferenceModule.mutations.removeRemoteMedia(state, participantId)
assert.notExists(state.remoteMediaStreams[participantId])
})
it('should store the selected remote participant as selected', () => {
const state = {
selectedParticipant: null
}
const participantId = '123456789'
ConferenceModule.mutations.setSelectedParticipant(state, participantId)
assert.equal(state.selectedParticipant, participantId)
})
it('should store the local participant as selected if current selected participant leaves', () => {
const state = {
selectedParticipant: '123456789',
participants: []
}
const participantId = '123456789'
ConferenceModule.mutations.setSelectedParticipant(state, participantId)
assert.equal(state.selectedParticipant, 'local')
})
it('should reset the selected participant when conference ends', () => {
const state = {
selectedParticipant: 'local',
joinState: false
}
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 { assert } from 'chai';
import ConversationsModule from '../../src/store/conversations/conversations'
import { assert } from 'chai'
describe('Conversations', function(){
describe('Conversations', function () {
it('should load next page of items', function () {
const resultItems = []
const state = {
items: [
{
call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: 'call',
callee: '43993006',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
]
}
const data = {
items: [
{
call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: 'call',
callee: '43993006',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
],
lastPage: 1
}
resultItems.push(state.items[0])
resultItems.push(data.items[0])
ConversationsModule.mutations.nextPageSucceeded(state, data)
assert.deepEqual(state.items, resultItems)
})
it('should load next page of items', function(){
let resultItems = [];
let state = {
items: [
{
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29",
call_type: "call",
callee: "43993006",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 85,
rating_status: "ok",
start_time: "2018-06-21 14:50:00.687",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
}
]
};
let data = {
items: [
{
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29",
call_type: "call",
callee: "43993006",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 85,
rating_status: "ok",
start_time: "2018-06-21 14:50:00.687",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
}
],
lastPage: 1
};
resultItems.push(state.items[0]);
resultItems.push(data.items[0]);
ConversationsModule.mutations.nextPageSucceeded(state, data);
assert.deepEqual(state.items, resultItems);
});
it('should load reloaded items', function () {
const state = {
items: [
{
call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: 'call',
callee: '43993006',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
]
}
const data = {
items: [
{
call_id: 'd2212956-46cc-4f9d-805d-cf2b5f572726',
call_type: 'call',
callee: '43993007',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 87,
rating_status: 'ok',
start_time: '2018-06-21 15:02:41.762',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
},
{
call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: 'call',
callee: '43993006',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
],
lastPage: 1
}
ConversationsModule.mutations.reloadItemsSucceeded(state, data)
assert.deepEqual(state.items, data.items)
})
it('should load reloaded items', function(){
let state = {
items: [
{
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29",
call_type: "call",
callee: "43993006",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 85,
rating_status: "ok",
start_time: "2018-06-21 14:50:00.687",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
}
]
};
let data = {
items: [
{
call_id: "d2212956-46cc-4f9d-805d-cf2b5f572726",
call_type: "call",
callee: "43993007",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 87,
rating_status: "ok",
start_time: "2018-06-21 15:02:41.762",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
},
{
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29",
call_type: "call",
callee: "43993006",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 85,
rating_status: "ok",
start_time: "2018-06-21 14:50:00.687",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
}
],
lastPage: 1
};
ConversationsModule.mutations.reloadItemsSucceeded(state, data);
assert.deepEqual(state.items, data.items);
});
it('should load blocked numbers and mode', function(){
let state = {
blockedNumbersIncoming: new Set(),
blockedModeIncoming: null,
blockedNumbersOutgoing: new Set(),
blockedModeOutgoing: null
};
let options = {
blockAnonymous: undefined,
enabled: undefined,
list: [
"123456",
"555555"
]
};
let listSet = new Set(["123456", "555555"]);
ConversationsModule.mutations.blockedIncomingSucceeded(state, options);
ConversationsModule.mutations.blockedOutgoingSucceeded(state, options);
assert.deepEqual(state.blockedNumbersIncoming, listSet);
assert.equal(state.blockedModeIncoming, 'blacklist');
assert.deepEqual(state.blockedNumbersOutgoing, listSet);
assert.equal(state.blockedModeOutgoing, 'blacklist');
});
});
it('should load blocked numbers and mode', function () {
const state = {
blockedNumbersIncoming: new Set(),
blockedModeIncoming: null,
blockedNumbersOutgoing: new Set(),
blockedModeOutgoing: null
}
const options = {
blockAnonymous: undefined,
enabled: undefined,
list: [
'123456',
'555555'
]
}
const listSet = new Set(['123456', '555555'])
ConversationsModule.mutations.blockedIncomingSucceeded(state, options)
ConversationsModule.mutations.blockedOutgoingSucceeded(state, options)
assert.deepEqual(state.blockedNumbersIncoming, listSet)
assert.equal(state.blockedModeIncoming, 'blacklist')
assert.deepEqual(state.blockedNumbersOutgoing, listSet)
assert.equal(state.blockedModeOutgoing, 'blacklist')
})
})

@ -1,72 +1,70 @@
'use strict';
'use strict'
import PbxConfig from '../../src/store/pbx-config';
import { assert } from 'chai';
import PbxConfig from '../../src/store/pbx-config'
import { assert } from 'chai'
describe('PBX Configuration Store', () => {
it('should list all PBX Groups', () => {
let state = {};
let data = {
pilot: {},
seats: {
2: {
id: 2,
pbx_group_ids: []
},
3:
it('should list all PBX Groups', () => {
const state = {}
const data = {
pilot: {},
seats: {
2: {
id: 2,
pbx_group_ids: []
},
3:
{
id: 3,
pbx_group_ids: []
}
},
lastPage: 1,
groups: {
4: {
id: 4,
display_name: 'Marketing'
id: 3,
pbx_group_ids: []
}
},
numbers: [
{
id: 6
},
{
id: 7
}
]
};
PbxConfig.mutations.listSucceeded(state, data);
assert.equal(state.seats, data.seats);
assert.equal(state.groups, data.groups);
assert.deepEqual(state.numbers, data.numbers);
});
it('should list all Sound Sets', () => {
let state = {};
let data = {
items: [
{
contract_defaults: true,
customer_id: null,
description: 'Set description 1',
groups: [],
id: 15,
name: 'Set 1'
},
{
contract_defaults: false,
customer_id: null,
description: 'Set description 2',
groups: [],
id: 17,
name: 'Set 2'
}
]
};
PbxConfig.mutations.listSoundSetsSucceeded(state, data);
assert.equal(state.soundSets[15], data.items[0]);
assert.equal(state.soundSets[17], data.items[1]);
});
},
lastPage: 1,
groups: {
4: {
id: 4,
display_name: 'Marketing'
}
},
numbers: [
{
id: 6
},
{
id: 7
}
]
}
PbxConfig.mutations.listSucceeded(state, data)
assert.equal(state.seats, data.seats)
assert.equal(state.groups, data.groups)
assert.deepEqual(state.numbers, data.numbers)
})
});
it('should list all Sound Sets', () => {
const state = {}
const data = {
items: [
{
contract_defaults: true,
customer_id: null,
description: 'Set description 1',
groups: [],
id: 15,
name: 'Set 1'
},
{
contract_defaults: false,
customer_id: null,
description: 'Set description 2',
groups: [],
id: 17,
name: 'Set 2'
}
]
}
PbxConfig.mutations.listSoundSetsSucceeded(state, data)
assert.equal(state.soundSets[15], data.items[0])
assert.equal(state.soundSets[17], data.items[1])
})
})

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

@ -1,17 +1,16 @@
'use strict';
'use strict'
import UserModule from '../../src/store/user';
import { assert } from 'chai';
import UserModule from '../../src/store/user'
import { assert } from 'chai'
describe('UserModule', ()=>{
it('should login', ()=>{
var state = {};
UserModule.mutations.loginSucceeded(state, {
jwt: 'abc123',
subscriberId: 123
});
assert.equal(state.jwt, 'abc123');
assert.equal(state.subscriberId, '123');
});
});
describe('UserModule', () => {
it('should login', () => {
var state = {}
UserModule.mutations.loginSucceeded(state, {
jwt: 'abc123',
subscriberId: 123
})
assert.equal(state.jwt, 'abc123')
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 { i18n } from '../../src/i18n';
import { assert } from 'chai';
import { i18n } from '../../src/i18n'
import { assert } from 'chai'
describe('Voicebox', function(){
describe('Voicebox', function () {
it('should load all voicebox settings into store', function () {
const state = {
voiceboxSettingDelete: false,
voiceboxSettingAttach: false,
voiceboxSettingPin: '',
voiceboxSettingEmail: ''
}
const settings = {
attach: true,
delete: false,
email: '',
id: 123,
pin: 1234,
sms_number: ''
}
VoiceboxModule.mutations.loadSettingsSucceeded(state, settings)
assert.equal(state.voiceboxSettingDelete, settings.delete)
assert.equal(state.voiceboxSettingAttach, settings.attach)
assert.equal(state.voiceboxSettingEmail, settings.email)
assert.equal(state.voiceboxSettingPin, settings.pin)
})
it('should load all voicebox settings into store', function(){
let state = {
voiceboxSettingDelete: false,
voiceboxSettingAttach: false,
voiceboxSettingPin: '',
voiceboxSettingEmail: '',
};
let settings = {
attach: true,
delete: false,
email: '',
id: 123,
pin: 1234,
sms_number: ''
};
VoiceboxModule.mutations.loadSettingsSucceeded(state, settings);
assert.equal(state.voiceboxSettingDelete, settings.delete);
assert.equal(state.voiceboxSettingAttach, settings.attach);
assert.equal(state.voiceboxSettingEmail, settings.email);
assert.equal(state.voiceboxSettingPin, settings.pin);
it('should load all busy greeting id into store', function () {
const state = {
busyGreetingId: null
}
const greetings = [
{
id: 1
}
]
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings)
assert.deepEqual(state.busyGreetingId, greetings[0].id)
})
});
it('should load busy greeting id into store', function () {
const state = {
busyGreetingId: null
}
const greetings = [
{
id: 1
}
]
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings)
assert.deepEqual(state.busyGreetingId, greetings[0].id)
})
it('should load all busy greeting id into store', function(){
let state = {
busyGreetingId: null
};
let greetings = [
{
id: 1
}
];
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings);
assert.deepEqual(state.busyGreetingId, greetings[0].id);
});
it('should load unavailable greeting id into store', function () {
const state = {
unavailGreetingId: null
}
const greetings = [
{
id: 1
}
]
VoiceboxModule.mutations.loadUnavailGreetingSucceeded(state, greetings)
assert.deepEqual(state.unavailGreetingId, greetings[0].id)
})
it('should load busy greeting id into store', function(){
let state = {
busyGreetingId: null
};
let greetings = [
{
id: 1
}
];
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings);
assert.deepEqual(state.busyGreetingId, greetings[0].id);
});
it('should load busy greeting url into store', function () {
const state = {
playBusyGreetingUrl: null
}
const url = 'blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821'
VoiceboxModule.mutations.playBusyGreetingSucceeded(state, url)
assert.deepEqual(state.playBusyGreetingUrl, url)
})
it('should load unavailable greeting id into store', function(){
let state = {
unavailGreetingId: null
};
let greetings = [
{
id: 1
}
];
VoiceboxModule.mutations.loadUnavailGreetingSucceeded(state, greetings);
assert.deepEqual(state.unavailGreetingId, greetings[0].id);
});
it('should load unavailable greeting id into store', function () {
const state = {
playUnavailGreetingUrl: null
}
const url = 'blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821'
VoiceboxModule.mutations.playUnavailGreetingSucceeded(state, url)
assert.deepEqual(state.playUnavailGreetingUrl, url)
})
it('should load busy greeting url into store', function(){
let state = {
playBusyGreetingUrl: null
};
let url = "blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821";
VoiceboxModule.mutations.playBusyGreetingSucceeded(state, url);
assert.deepEqual(state.playBusyGreetingUrl, url);
});
it('should get right label for busy greeting to indicate if it\'s custom or default', function () {
const state = {
busyGreetingId: null
}
const getterObject = VoiceboxModule.getters.busyGreetingLabel(state)
assert.equal(getterObject, i18n.t('voicebox.label.defaultSoundActive'))
})
it('should load unavailable greeting id into store', function(){
let state = {
playUnavailGreetingUrl: null
};
let url = "blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821";
VoiceboxModule.mutations.playUnavailGreetingSucceeded(state, url);
assert.deepEqual(state.playUnavailGreetingUrl, url);
});
it('should get right label for busy greeting to indicate if it\'s custom or default', function(){
let state = {
busyGreetingId: null
};
let getterObject = VoiceboxModule.getters.busyGreetingLabel(state);
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(){
let state = {
unavailGreetingId: 1
};
let getterObject = VoiceboxModule.getters.unavailGreetingLabel(state);
assert.equal(getterObject, i18n.t('voicebox.label.customSoundActive'));
});
});
it('should get right label for unavailable greeting to indicate if it\'s custom or default', function () {
const state = {
unavailGreetingId: 1
}
const getterObject = VoiceboxModule.getters.unavailGreetingLabel(state)
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'
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() {
let today = new Date('2000-01-01 00:00:00');
let beforeYesterday = new Date('1999-12-30 00:00:00');
let tomorrow = new Date('2000-01-02 00:00:00');
const yesterday1 = new Date('1999-12-31 00:00:00')
const yesterday2 = new Date('1999-12-31 14:00:00')
const yesterday3 = new Date('1999-12-31 23:59:59')
let yesterday1 = new Date('1999-12-31 00:00:00');
let yesterday2 = new Date('1999-12-31 14:00:00');
let yesterday3 = new Date('1999-12-31 23:59:59');
assert.isTrue(isYesterday(yesterday1, today))
assert.isTrue(isYesterday(yesterday2, today))
assert.isTrue(isYesterday(yesterday3, today))
assert.isTrue(isYesterday(yesterday1, today));
assert.isTrue(isYesterday(yesterday2, today));
assert.isTrue(isYesterday(yesterday3, today));
assert.isFalse(isYesterday(beforeYesterday, today))
assert.isFalse(isYesterday(today, today))
assert.isFalse(isYesterday(tomorrow, today))
})
assert.isFalse(isYesterday(beforeYesterday, today));
assert.isFalse(isYesterday(today, today));
assert.isFalse(isYesterday(tomorrow, today));
});
it('should check whether a given date is today or not', function () {
const today = new Date('2000-01-01 00:00:00')
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() {
let today = new Date('2000-01-01 00:00:00');
let yesterday = new Date('1999-12-31 00:00:00');
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');
const today1 = new Date('2000-01-01 00:00:00')
const today2 = new Date('2000-01-01 14:00:00')
const today3 = new Date('2000-01-01 23:59:59')
let today1 = new Date('2000-01-01 00:00:00');
let today2 = new Date('2000-01-01 14:00:00');
let today3 = new Date('2000-01-01 23:59:59');
assert.isTrue(isToday(today, today))
assert.isTrue(isToday(today1, today))
assert.isTrue(isToday(today2, today))
assert.isTrue(isToday(today3, today))
assert.isTrue(isToday(today, today));
assert.isTrue(isToday(today1, today));
assert.isTrue(isToday(today2, today));
assert.isTrue(isToday(today3, today));
assert.isFalse(isToday(beforeYesterday, today))
assert.isFalse(isToday(yesterday, today))
assert.isFalse(isToday(tomorrow, today))
assert.isFalse(isToday(afterTomorrow, today))
})
assert.isFalse(isToday(beforeYesterday, today));
assert.isFalse(isToday(yesterday, today));
assert.isFalse(isToday(tomorrow, today));
assert.isFalse(isToday(afterTomorrow, today));
});
it('should check whether a given date is within last week or not', function () {
const today = new Date('2000-01-01 00:00:00')
const validDay1 = new Date('1999-12-31 00:00:00')
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');
let validDay1 = new Date('1999-12-31 00:00:00');
let validDay2 = new Date('1999-12-30 00:00:00');
let validDay3 = new Date('1999-12-29 00:00:00');
let validDay4 = new Date('1999-12-28 00:00:00');
let validDay5 = new Date('1999-12-27 00:00:00');
let validDay6 = new Date('1999-12-26 00:00:00');
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))
let invalidDay1 = new Date('1999-12-25 00:00:00');
let invalidDay2 = new Date('1999-12-24 00:00:00');
let invalidDay3 = new Date('1999-12-23 00:00:00');
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));
});
});
assert.isFalse(isWithinLastWeek(today, today))
assert.isFalse(isWithinLastWeek(invalidDay1, today))
assert.isFalse(isWithinLastWeek(invalidDay2, today))
assert.isFalse(isWithinLastWeek(invalidDay3, today))
})
})

@ -1,44 +1,42 @@
'use strict';
'use strict'
import { assert } from 'chai';
import numberFormat from '../../src/filters/number-format';
import { normalizeDestination } from '../../src/filters/number-format';
import { assert } from 'chai'
import numberFormat, { normalizeDestination } from '../../src/filters/number-format'
const numbers = {
valid1: '43993004',
invalid1: '43993004+',
invalid2: 'a43993004',
};
valid1: '43993004',
invalid1: '43993004+',
invalid2: 'a43993004'
}
const sipUris = {
valid1: 'sip:43993004@sipwise.com',
invalid1: 'sip:a43993004@sipwise.com'
};
valid1: 'sip:43993004@sipwise.com',
invalid1: 'sip:a43993004@sipwise.com'
}
const destinations = {
voiceMail: 'sip:vmu@voicebox.local',
fax2Mail: 'sip:@fax2mail.local',
managerSecretary: 'sip:@managersecretary.local',
app: 'sip:app@app.local',
customHours: 'sip:custom-hours@app.local',
conference: 'sip:@conference.local',
number: 'sip:43993004@sipwise.com'
};
voiceMail: 'sip:vmu@voicebox.local',
fax2Mail: 'sip:@fax2mail.local',
managerSecretary: 'sip:@managersecretary.local',
app: 'sip:app@app.local',
customHours: 'sip:custom-hours@app.local',
conference: 'sip:@conference.local',
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(){
assert.equal(numberFormat(sipUris.valid1), numbers.valid1);
assert.equal(numberFormat(sipUris.invalid1), numbers.invalid2);
});
it('should format a call forward destination', function(){
assert.equal(normalizeDestination(destinations.voiceMail), 'Voicebox');
assert.equal(normalizeDestination(destinations.fax2Mail), 'Fax2Mail');
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);
});
});
it('should format a call forward destination', function () {
assert.equal(normalizeDestination(destinations.voiceMail), 'Voicebox')
assert.equal(normalizeDestination(destinations.fax2Mail), 'Fax2Mail')
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 {
userInfo,
customMacAddress
userInfo,
customMacAddress
} from '../../src/helpers/validation'
describe('Userinfo validation helper', function() {
it('should validate userinfo consisting of phone number and country code', function() {
let input = "+439988776655";
assert.isTrue(userInfo(input));
});
it('should validate userinfo with parameter', function() {
let input = "+358-555-1234567;postd=pp22";
assert.isTrue(userInfo(input));
});
it('should validate userinfo consisting of subscriber username', function() {
let input = "alice";
assert.isTrue(userInfo(input));
});
it('should not validate invalid userinfo characters', function() {
let input = "al)<e";
assert.isFalse(userInfo(input));
});
});
describe('Custom mac address validation helper', function() {
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() {
let input = "13-14-5f-cD-42-5f";
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() {
let input = "13:14:5f:cD:42-5f";
assert.isFalse(customMacAddress(input));
});
it('should not validate mac address when invalid', function() {
let input = "k183p1r23411";
assert.isFalse(customMacAddress(input));
});
});
describe('Userinfo validation helper', function () {
it('should validate userinfo consisting of phone number and country code', function () {
const input = '+439988776655'
assert.isTrue(userInfo(input))
})
it('should validate userinfo with parameter', function () {
const input = '+358-555-1234567;postd=pp22'
assert.isTrue(userInfo(input))
})
it('should validate userinfo consisting of subscriber username', function () {
const input = 'alice'
assert.isTrue(userInfo(input))
})
it('should not validate invalid userinfo characters', function () {
const input = 'al)<e'
assert.isFalse(userInfo(input))
})
})
describe('Custom mac address validation helper', function () {
it('should validate mac address separated by colon', function () {
const 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 without separator', function () {
const 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 when invalid', function () {
const input = 'k183p1r23411'
assert.isFalse(customMacAddress(input))
})
})

@ -1,12 +1,12 @@
<template>
<div></div>
<div />
</template>
<script>
export default {
data () {
return {}
}
data () {
return {}
}
}
</script>

@ -1,18 +1,18 @@
<template>
<!-- Configure "view" prop for QLayout -->
<q-layout>
<q-toolbar slot="header">
<!-- opens drawer below
<!-- Configure "view" prop for QLayout -->
<q-layout>
<q-toolbar slot="header">
<!-- opens drawer below
<button class="hide-on-drawer-visible" @click="$refs.drawer.open()">
<i>menu</i>
</button>
-->
<q-toolbar-title>
Title
</q-toolbar-title>
</q-toolbar>
<q-toolbar-title>
Title
</q-toolbar-title>
</q-toolbar>
<!-- Navigation Tabs
<!-- Navigation Tabs
<q-tabs slot="navigation">
<q-route-tab slot="title" icon="view_quilt" to="/layout/about" replace hide="icon" label="About" />
<q-route-tab slot="title" icon="view_day" to="/layout/toolbar" replace hide="icon" label="Toolbar" />
@ -21,7 +21,7 @@
</q-tabs>
-->
<!-- Left Side Panel
<!-- Left Side Panel
<div slot="left">
<q-list no-border link inset-delimiter>
<q-list-header>Essential Links</q-list-header>
@ -45,27 +45,27 @@
</div>
-->
<!-- Right Side Panel
<!-- Right Side Panel
<div slot="right">
...
</div>
-->
<router-view />
<router-view />
<!-- Footer
<!-- Footer
<q-toolbar slot="footer">
...
</q-toolbar>
-->
</q-layout>
</q-layout>
</template>
<script>
export default {
data () {
return {}
}
data () {
return {}
}
}
</script>

@ -1,15 +1,15 @@
<template>
<!-- if you want automatic padding use "layout-padding" class -->
<div class="layout-padding">
<!-- your content -->
</div>
<!-- if you want automatic padding use "layout-padding" class -->
<div class="layout-padding">
<!-- your content -->
</div>
</template>
<script>
export default {
data () {
return {}
}
data () {
return {}
}
}
</script>

@ -1,24 +1,29 @@
<template>
<div>
<p class="textContent">{{ input }}</p>
<span>{{ counter }}</span>
<q-btn id="mybutton" @click="increment()"></q-btn>
</div>
<div>
<p class="textContent">
{{ input }}
</p>
<span>{{ counter }}</span>
<q-btn
id="mybutton"
@click="increment()"
/>
</div>
</template>
<script>
export default {
name: 'QBUTTON',
data () {
return {
counter: 0,
input: 'rocket muffin'
}
},
methods: {
increment () {
this.counter++
}
}
name: 'QBUTTON',
data () {
return {
counter: 0,
input: 'rocket muffin'
}
},
methods: {
increment () {
this.counter++
}
}
}
</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
setTimeout(()=>{
// do nothing
setTimeout(() => {
// do nothing
}, 1)

@ -6,65 +6,65 @@ import VueRouter from 'vue-router'
import Quasar, { Cookies } from 'quasar'
const mockSsrContext = () => {
return {
req: {
headers: {}
},
res: {
setHeader: () => undefined
}
}
return {
req: {
headers: {}
},
res: {
setHeader: () => undefined
}
}
}
// https://eddyerburgh.me/mock-vuex-in-vue-unit-tests
export const mountQuasar = (component, options = {}) => {
const localVue = createLocalVue()
const app = {}
const localVue = createLocalVue()
const app = {}
localVue.use(Vuex)
localVue.use(VueRouter)
localVue.use(Quasar)
const store = new Vuex.Store({})
const router = new VueRouter()
localVue.use(Vuex)
localVue.use(VueRouter)
localVue.use(Quasar)
const store = new Vuex.Store({})
const router = new VueRouter()
if (options) {
const ssrContext = options.ssr ? mockSsrContext() : null
if (options) {
const ssrContext = options.ssr ? mockSsrContext() : null
if (options.cookies) {
const cookieStorage = ssrContext ? Cookies.parseSSR(ssrContext) : Cookies
const cookies = options.cookies
Object.keys(cookies).forEach(key => {
cookieStorage.set(key, cookies[key])
})
}
if (options.cookies) {
const cookieStorage = ssrContext ? Cookies.parseSSR(ssrContext) : Cookies
const cookies = options.cookies
Object.keys(cookies).forEach(key => {
cookieStorage.set(key, cookies[key])
})
}
if (options.plugins) {
options.plugins.forEach(plugin => {
plugin({ app, store, router, Vue: localVue, ssrContext })
})
}
}
if (options.plugins) {
options.plugins.forEach(plugin => {
plugin({ app, store, router, Vue: localVue, ssrContext })
})
}
}
// mock vue-i18n
const $t = () => {}
const $tc = () => {}
const $n = () => {}
const $d = () => {}
// mock vue-i18n
const $t = () => {}
const $tc = () => {}
const $n = () => {}
const $d = () => {}
return shallowMount(component, {
localVue: localVue,
store,
router,
mocks: { $t, $tc, $n, $d },
// Injections for Components with a QPage root Element
provide: {
pageContainer: true,
layout: {
header: {},
right: {},
footer: {},
left: {}
}
}
})
return shallowMount(component, {
localVue: localVue,
store,
router,
mocks: { $t, $tc, $n, $d },
// Injections for Components with a QPage root Element
provide: {
pageContainer: true,
layout: {
header: {},
right: {},
footer: {},
left: {}
}
}
})
}

Loading…
Cancel
Save