@ -9,16 +9,17 @@ import { getMappings, getSourcesets, getTimesets,
addDestinationToDestinationset ,
convertTimesetToWeekdays ,
getHoursFromRange ,
getDaysFromRange } from '../../src/api/call-forward' ;
getDaysFromRange ,
deleteTimeFromTimeset } from '../../src/api/call-forward' ;
import { assert } from 'chai' ;
Vue . use ( VueResource ) ;
describe ( 'CallForward' , function ( ) {
describe ( 'CallForward' , function ( ) {
const subscriberId = 123 ;
it ( 'should get all call forward mappings' , function ( done ) {
it ( 'should get all call forward mappings' , function ( done ) {
let data = {
"cfb" : [ {
@ -52,20 +53,20 @@ describe('CallForward', function(){
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( data ) , {
status : 200
} ) ) ;
} ) ;
getMappings ( subscriberId ) . then ( ( result ) => {
getMappings ( subscriberId ) . then ( ( result ) => {
assert . deepEqual ( result , data ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should get all call forward sourcesets' , function ( done ) {
it ( 'should get all call forward sourcesets' , function ( done ) {
let innerData = [ {
"_links" : {
@ -103,20 +104,20 @@ describe('CallForward', function(){
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( data ) , {
status : 200
} ) ) ;
} ) ;
getSourcesets ( subscriberId ) . then ( ( result ) => {
getSourcesets ( subscriberId ) . then ( ( result ) => {
assert . deepEqual ( result , innerData ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should get all call forward timesets' , function ( done ) {
it ( 'should get all call forward timesets' , function ( done ) {
let innerData = [ {
"_links" : {
@ -164,20 +165,20 @@ describe('CallForward', function(){
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( data ) , {
status : 200
} ) ) ;
} ) ;
getTimesets ( subscriberId ) . then ( ( result ) => {
getTimesets ( subscriberId ) . then ( ( result ) => {
assert . deepEqual ( result , innerData ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should get all call forward destinationsets' , function ( done ) {
it ( 'should get all call forward destinationsets' , function ( done ) {
let innerData = [ {
"_links" : {
@ -221,20 +222,20 @@ describe('CallForward', function(){
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( data ) , {
status : 200
} ) ) ;
} ) ;
getDestinationsets ( subscriberId ) . then ( ( result ) => {
getDestinationsets ( subscriberId ) . then ( ( result ) => {
assert . deepEqual ( result , innerData ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should get all call forward destinationset by id' , function ( done ) {
it ( 'should get all call forward destinationset by id' , function ( done ) {
let data = {
"_links" : {
@ -322,20 +323,20 @@ describe('CallForward', function(){
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( data ) , {
status : 200
} ) ) ;
} ) ;
getDestinationsetById ( '3' ) . then ( ( result ) => {
getDestinationsetById ( '3' ) . then ( ( result ) => {
assert . deepEqual ( result , responseData ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should delete destination from call forward destinationset' , function ( done ) {
it ( 'should delete destination from call forward destinationset' , function ( done ) {
let options = {
id : 3 ,
@ -355,15 +356,15 @@ describe('CallForward', function(){
status : 204
} ) ) ;
} ) ;
deleteDestinationFromDestinationset ( options ) . then ( ( result ) => {
deleteDestinationFromDestinationset ( options ) . then ( ( result ) => {
assert . isOk ( result ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should add destination to call forward destinationset' , function ( done ) {
it ( 'should add destination to call forward destinationset' , function ( done ) {
let options = {
id : 3 ,
@ -375,16 +376,43 @@ describe('CallForward', function(){
}
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( { } ) , {
status : 204
} ) ) ;
} ) ;
addDestinationToDestinationset ( options ) . then ( ( result ) => {
assert . isOk ( result ) ;
done ( ) ;
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
it ( 'should delete time entry from call forward timeset' , function ( done ) {
let options = {
timesetId : 3 ,
times : {
"weekday" : "1" ,
"wday" : "Monday" ,
"hour" : "8-16" ,
"from" : "8" ,
"to" : "16"
}
} ;
Vue . http . interceptors = [ ] ;
Vue . http . interceptors . unshift ( ( request , next ) => {
next ( request . respondWith ( JSON . stringify ( { } ) , {
status : 204
} ) ) ;
} ) ;
addDestinationToDestinationset ( options ) . then ( ( result ) => {
deleteTimeFromTime set( options ) . then ( ( result ) => {
assert . isOk ( result ) ;
done ( ) ;
} ) . catch ( ( err ) => {
} ) . catch ( ( err ) => {
done ( err ) ;
} ) ;
} ) ;
@ -414,7 +442,7 @@ describe('CallForward', function(){
hour : "6-8" ,
minute : null ,
to : "9:00" ,
wday : "1 -2 ",
wday : "1 ",
weekday : "Sunday"
} ,
{
@ -422,14 +450,15 @@ describe('CallForward', function(){
hour : "6-8" ,
minute : null ,
to : "9:00" ,
wday : " 1- 2",
wday : " 2",
weekday : "Monday"
}
] ,
timesetIsCompatible : true ,
timesetExists : true ,
timesetHasDuplicate : false ,
timesetHasReverse : false ,
timesetIsCompatible : true
timesetHasDuplicate : false ,
timesetId : 1
} ;
assert . deepEqual ( convertTimesetToWeekdays ( options ) , convertedData ) ;
@ -458,57 +487,58 @@ describe('CallForward', function(){
times : [
{
from : "6:0" ,
hour : "6 -8 ",
hour : "6 ",
minute : "0-30" ,
to : "6:31" ,
wday : "1 -2 ",
wday : "1 ",
weekday : "Sunday"
} ,
{
from : "7:0" ,
hour : " 6-8 ",
hour : " 7 ",
minute : "0-30" ,
to : "7:31" ,
wday : "1 -2 ",
wday : "1 ",
weekday : "Sunday"
} ,
{
from : "8:0" ,
hour : " 6- 8",
hour : " 8",
minute : "0-30" ,
to : "8:31" ,
wday : "1 -2 ",
wday : "1 ",
weekday : "Sunday"
} ,
{
from : "6:0" ,
hour : "6 -8 ",
hour : "6 ",
minute : "0-30" ,
to : "6:31" ,
wday : " 1- 2",
wday : " 2",
weekday : "Monday"
} ,
{
from : "7:0" ,
hour : " 6-8 ",
hour : " 7 ",
minute : "0-30" ,
to : "7:31" ,
wday : " 1- 2",
wday : " 2",
weekday : "Monday"
} ,
{
from : "8:0" ,
hour : " 6- 8",
hour : " 8",
minute : "0-30" ,
to : "8:31" ,
wday : " 1- 2",
wday : " 2",
weekday : "Monday"
}
] ,
timesetIsCompatible : true ,
timesetExists : true ,
timesetHasDuplicate : false ,
timesetHasReverse : false ,
timesetIsCompatible : true
timesetHasDuplicate : false ,
timesetId : 1
} ;
assert . deepEqual ( convertTimesetToWeekdays ( options ) , convertedData ) ;
@ -547,7 +577,8 @@ describe('CallForward', function(){
timesetExists : true ,
timesetHasDuplicate : false ,
timesetHasReverse : false ,
timesetIsCompatible : true
timesetIsCompatible : true ,
timesetId : 1
} ;
assert . deepEqual ( convertTimesetToWeekdays ( options ) , convertedData ) ;