- CallBlocking: As a Customer I want to add a new number (outgoing) - CallBlocking: As a Customer I want to edit a number (outgoing) - CallBlocking: As a Customer I want to enable/disable the functionality (outgoing) - CallBlocking: As a Customer I want to remove a number from the list (outgoing) - CallBlocking: As a Customer I want to edit a number (incoming) Change-Id: Ia456af57ef202dbf774739c5b9a5eb9955eaf9b8changes/69/16269/2
parent
649d1476ad
commit
70aef2b5c5
@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<q-toggle
|
||||
:label="label"
|
||||
@input="toggle()"
|
||||
v-model="toggleState" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { QToggle } from 'quasar-framework'
|
||||
export default {
|
||||
name: 'csc-toggle',
|
||||
props: [
|
||||
'enabled',
|
||||
'label'
|
||||
],
|
||||
data () {
|
||||
return {
|
||||
toggleState: this.enabled,
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
this.toggleState = this.enabled;
|
||||
},
|
||||
components: {
|
||||
QToggle
|
||||
},
|
||||
methods: {
|
||||
toggle() {
|
||||
this.$emit('change', this.toggleState);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
@ -0,0 +1,219 @@
|
||||
<template>
|
||||
<page :title="$t('pages.callBlocking' + suffix + '.title')">
|
||||
<q-field id="toggle-call-blocking">
|
||||
<csc-toggle :label="toggleButtonLabel" @change="toggle" :enabled="enabled"/>
|
||||
</q-field>
|
||||
<div id="add-number-form">
|
||||
<q-field v-if="!addFormEnabled">
|
||||
<q-btn color="primary"
|
||||
icon="fa-plus"
|
||||
@click="enableAddForm()">{{ $t('pages.callBlocking' + suffix + '.addNumberButton') }}</q-btn>
|
||||
</q-field>
|
||||
<div v-if="addFormEnabled">
|
||||
<q-field :error="addFormError" :error-label="$t('pages.callBlocking' + suffix + '.addInputError')">
|
||||
<q-input type="text" float-label="Number" v-model="newNumber" clearable @keyup.enter="addNumber()" />
|
||||
</q-field>
|
||||
<q-btn @click="disableAddForm()">{{ $t('buttons.cancel') }}</q-btn>
|
||||
<q-btn color="primary" icon-right="fa-save" @click="addNumber()">{{ $t('buttons.save') }}</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<q-card class="blocked-number" v-for="(number, index) in numbers">
|
||||
<q-card-title>
|
||||
<span v-if="!(editing && editingIndex == index)" @click="editNumber(index)">{{ number }}</span>
|
||||
<q-input autofocus v-if="editing && editingIndex == index" type="text" float-label="Number"
|
||||
v-model="editingNumber" @keyup.enter="saveNumber(index)" />
|
||||
<q-icon v-if="editing && editingIndex == index" slot="right"
|
||||
name="fa-save" @click="saveNumber(index)" class="cursor-pointer"></q-icon>
|
||||
<q-icon v-if="!(editing && editingIndex == index)" slot="right"
|
||||
name="fa-edit" @click="editNumber(index)" class="cursor-pointer"></q-icon>
|
||||
<q-icon v-if="!(editing && editingIndex == index)" slot="right"
|
||||
name="fa-remove" @click="removeNumber(index)" class="cursor-pointer"></q-icon>
|
||||
</q-card-title>
|
||||
</q-card>
|
||||
<q-inner-loading :visible="listLoading">
|
||||
<q-spinner-mat size="50px" color="primary"></q-spinner-mat>
|
||||
</q-inner-loading>
|
||||
</div>
|
||||
</page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash';
|
||||
import { startLoading, stopLoading, showGlobalError, showToast } from '../../../helpers/ui'
|
||||
import Page from '../../Page'
|
||||
import CscToggle from '../../form/CscToggle'
|
||||
import { QInput, QCard, QBtn, QField, QIcon, QCardTitle, Dialog, QSpinnerMat, QToggle,
|
||||
Toast, QList, QItem, QItemMain, QCardMain, QInnerLoading } from 'quasar-framework'
|
||||
export default {
|
||||
name: 'csc-call-blocking',
|
||||
props: [
|
||||
'pageName',
|
||||
'title',
|
||||
'loadMethod',
|
||||
'addMethod',
|
||||
'editMethod',
|
||||
'removeMethod',
|
||||
'toggleMethod'
|
||||
],
|
||||
data () {
|
||||
return {
|
||||
addFormEnabled: false,
|
||||
addFormError: false,
|
||||
newNumber: '',
|
||||
listLoading: false,
|
||||
editing: false,
|
||||
editingIndex: 0,
|
||||
editingNumber: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.listLoading = true;
|
||||
this.$store.dispatch('callBlocking/load' + this.suffix).then(()=>{
|
||||
this.listLoading = false;
|
||||
}).catch((err)=>{
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
components: {
|
||||
Page,
|
||||
QToggle,
|
||||
Toast,
|
||||
QField,
|
||||
QBtn,
|
||||
QCard,
|
||||
QInput,
|
||||
QList,
|
||||
QItem,
|
||||
QItemMain,
|
||||
QCardMain,
|
||||
QIcon,
|
||||
QCardTitle,
|
||||
Dialog,
|
||||
QInnerLoading,
|
||||
QSpinnerMat,
|
||||
CscToggle
|
||||
},
|
||||
computed: {
|
||||
numbers (){
|
||||
return this.$store.state.callBlocking[this.pageName + 'List'];
|
||||
},
|
||||
enabled () {
|
||||
return this.$store.state.callBlocking[this.pageName + 'Enabled'];
|
||||
},
|
||||
toggleButtonLabel() {
|
||||
if(!this.enabled) {
|
||||
return this.$i18n.t('pages.callBlocking' + this.suffix + '.toggleEnableLabel');
|
||||
} else {
|
||||
return this.$i18n.t('pages.callBlocking' + this.suffix + '.toggleDisableLabel');
|
||||
}
|
||||
},
|
||||
toggleToastMessage() {
|
||||
if(this.enabled) {
|
||||
return this.$i18n.t('pages.callBlocking' + this.suffix + '.toggleEnabledToast');
|
||||
} else {
|
||||
return this.$i18n.t('pages.callBlocking' + this.suffix + '.toggleDisabledToast');
|
||||
}
|
||||
},
|
||||
suffix () {
|
||||
return _.upperFirst(this.pageName);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
enableAddForm() {
|
||||
this.addFormEnabled = true;
|
||||
this.newNumber = '';
|
||||
this.addFormError = false;
|
||||
},
|
||||
disableAddForm() {
|
||||
this.addFormEnabled = false;
|
||||
},
|
||||
addNumber() {
|
||||
this.listLoading = true;
|
||||
this.$store.dispatch('callBlocking/addNumber' + this.suffix, this.newNumber).then(()=>{
|
||||
this.disableAddForm();
|
||||
showToast(this.$i18n.t('pages.callBlocking' + this.suffix + '.addedToast', {
|
||||
number:this.newNumber
|
||||
}));
|
||||
this.listLoading = false;
|
||||
}).catch((err)=>{
|
||||
this.listLoading = false;
|
||||
this.addFormError = true;
|
||||
});
|
||||
},
|
||||
editNumber(index) {
|
||||
this.editing = true;
|
||||
this.editingIndex = index;
|
||||
this.editingNumber = this.numbers[index];
|
||||
},
|
||||
saveNumber(index) {
|
||||
this.editing = false;
|
||||
this.editingIndex = index;
|
||||
this.listLoading = true;
|
||||
if(this.numbers[index] !== this.editingNumber) {
|
||||
this.$store.dispatch('callBlocking/editNumber' + this.suffix, {
|
||||
index: index,
|
||||
number: this.editingNumber
|
||||
}).then(()=>{
|
||||
this.listLoading = false;
|
||||
}).catch((err)=>{
|
||||
this.listLoading = false;
|
||||
});
|
||||
} else {
|
||||
this.listLoading = false;
|
||||
}
|
||||
},
|
||||
removeNumber(index) {
|
||||
var store = this.$store;
|
||||
var state = this;
|
||||
var i18n = this.$i18n;
|
||||
Dialog.create({
|
||||
title: i18n.t('pages.callBlocking' + this.suffix + '.removeDialogTitle'),
|
||||
message: i18n.t('pages.callBlocking' + this.suffix + '.removeDialogText', {
|
||||
number: this.numbers[index]
|
||||
}),
|
||||
buttons: [
|
||||
'Cancel',
|
||||
{
|
||||
label: i18n.t('buttons.remove'),
|
||||
color: 'negative',
|
||||
handler () {
|
||||
state.listLoading = true;
|
||||
store.dispatch('callBlocking/removeNumber' + state.suffix, index).then(()=>{
|
||||
state.listLoading = false;
|
||||
showToast(i18n.t('pages.callBlocking' + state.suffix + '.removedToast', {
|
||||
number: state.numbers[index]
|
||||
}));
|
||||
}).catch((err)=>{
|
||||
state.listLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
toggle (enabled) {
|
||||
this.$store.dispatch('callBlocking/toggle' + this.suffix, enabled).then(()=>{
|
||||
showToast(this.toggleToastMessage);
|
||||
}).catch((err)=>{
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#toggle-call-blocking {
|
||||
margin-bottom:60px;
|
||||
}
|
||||
#add-number-form {
|
||||
margin-bottom:15px;
|
||||
}
|
||||
.blocked-number .q-card-title-extra .q-icon {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.blocked-number .q-input {
|
||||
margin:0;
|
||||
}
|
||||
</style>
|
@ -1,145 +1,18 @@
|
||||
<template>
|
||||
<page title="Block incoming calls">
|
||||
<q-field id="toggle-incoming">
|
||||
<q-toggle :label="((!callBlockingEnabled)?'Enable':'Disable') + ' Call Blocking'"
|
||||
@input="toggle()" v-model="callBlockingEnabled"/>
|
||||
</q-field>
|
||||
<div id="add-number-form">
|
||||
<q-field v-if="!addFormEnabled">
|
||||
<q-btn color="primary" icon="fa-plus" @click="enableAddForm()">Add number</q-btn>
|
||||
</q-field>
|
||||
<div v-if="addFormEnabled">
|
||||
<q-field :error="addFormError" error-label="Input a valid number or subscriber name">
|
||||
<q-input type="text" float-label="Number" v-model="newNumber"
|
||||
clearable @keyup.enter="saveNumber()" />
|
||||
</q-field>
|
||||
<q-btn @click="disableAddForm()">Cancel</q-btn>
|
||||
<q-btn color="primary" icon-right="fa-save" @click="saveNumber()">Save</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<q-card v-for="(number, index) in numbers">
|
||||
<q-card-title>
|
||||
{{ number }}
|
||||
<q-icon slot="right" name="fa-remove" @click="removeNumber(index)" class="cursor-pointer"></q-icon>
|
||||
</q-card-title>
|
||||
</q-card>
|
||||
<q-inner-loading :visible="listLoading">
|
||||
<q-spinner-gears size="50px" color="primary"></q-spinner-gears>
|
||||
</q-inner-loading>
|
||||
</div>
|
||||
</page>
|
||||
<csc-call-blocking page-name="incoming" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { startLoading, stopLoading, showGlobalError, showToast } from '../../../helpers/ui'
|
||||
import Page from '../../Page'
|
||||
import { QInput, QCard, QBtn, QField, QIcon, QCardTitle, Dialog, QSpinnerGears,
|
||||
QToggle, Toast, QList, QItem, QItemMain, QCardMain, QInnerLoading } from 'quasar-framework'
|
||||
import CscCallBlocking from './CscCallBlocking'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
callBlockingEnabled: false,
|
||||
addFormEnabled: false,
|
||||
addFormError: false,
|
||||
newNumber: '',
|
||||
listLoading: false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.listLoading = true;
|
||||
this.$store.dispatch('callBlocking/loadIncoming').then(()=>{
|
||||
this.callBlockingEnabled = this.$store.state.callBlocking.incomingEnabled;
|
||||
this.listLoading = false;
|
||||
}).catch((err)=>{
|
||||
this.listLoading = false;
|
||||
});
|
||||
return {}
|
||||
},
|
||||
components: {
|
||||
Page,
|
||||
QToggle,
|
||||
Toast,
|
||||
QField,
|
||||
QBtn,
|
||||
QCard,
|
||||
QInput,
|
||||
QList,
|
||||
QItem,
|
||||
QItemMain,
|
||||
QCardMain,
|
||||
QIcon,
|
||||
QCardTitle,
|
||||
Dialog,
|
||||
QInnerLoading,
|
||||
QSpinnerGears
|
||||
},
|
||||
computed: {
|
||||
numbers: {
|
||||
get(){
|
||||
return this.$store.state.callBlocking.incomingList;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
enableAddForm() {
|
||||
this.addFormEnabled = true;
|
||||
this.newNumber = '';
|
||||
this.addFormError = false;
|
||||
},
|
||||
disableAddForm() {
|
||||
this.addFormEnabled = false;
|
||||
},
|
||||
saveNumber() {
|
||||
this.listLoading = true;
|
||||
this.$store.dispatch('callBlocking/addNumberToIncoming', this.newNumber).then(()=>{
|
||||
this.disableAddForm();
|
||||
showToast('Added new number to list');
|
||||
this.listLoading = false;
|
||||
}).catch((err)=>{
|
||||
this.listLoading = false;
|
||||
this.addFormError = true;
|
||||
});
|
||||
|
||||
},
|
||||
removeNumber(index) {
|
||||
var store = this.$store;
|
||||
var state = this;
|
||||
Dialog.create({
|
||||
title: 'Remove number',
|
||||
message: 'You are about to remove the number',
|
||||
buttons: [
|
||||
'Cancel',
|
||||
{
|
||||
label: 'Remove',
|
||||
handler () {
|
||||
state.listLoading = true;
|
||||
store.dispatch('callBlocking/removeNumberFromIncoming', index).then(()=>{
|
||||
state.listLoading = false;
|
||||
showToast('Removed number from list');
|
||||
}).catch((err)=>{
|
||||
state.listLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
toggle () {
|
||||
this.$store.dispatch('callBlocking/toggleIncoming', this.callBlockingEnabled).then(()=>{
|
||||
showToast('Call blocking for incoming calls ' + ((this.callBlockingEnabled)?'enabled':'disabled'));
|
||||
}).catch((err)=>{
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
CscCallBlocking
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#toggle-incoming {
|
||||
margin-bottom:60px;
|
||||
}
|
||||
#add-number-form {
|
||||
margin-bottom:15px;
|
||||
}
|
||||
</style>
|
||||
|
@ -0,0 +1,310 @@
|
||||
'use strict';
|
||||
|
||||
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';
|
||||
|
||||
Vue.use(VueResource);
|
||||
|
||||
describe('CallBlocking', function(){
|
||||
|
||||
var subscriberId = 123;
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
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 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 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(list).concat(number)
|
||||
}), {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
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 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 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(list).concat(number)
|
||||
}), {
|
||||
status: 200
|
||||
}));
|
||||
} else if(request.method === 'PUT') {
|
||||
assert.deepEqual(request.body.block_in_list, list);
|
||||
next(request.respondWith('', {
|
||||
status: 200
|
||||
}));
|
||||
}
|
||||
});
|
||||
removeNumberFromOutgoingList(subscriberId, 0, number).then((result)=>{
|
||||
done();
|
||||
}).catch((err)=>{
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in new issue