You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.9 KiB
97 lines
2.9 KiB
|
|
'use strict';
|
|
|
|
import Vue from 'vue';
|
|
import VueResource from 'vue-resource';
|
|
import crypto from 'crypto-browserify'
|
|
import { getConversations } from '../../src/api/conversations';
|
|
import { assert } from 'chai';
|
|
|
|
Vue.use(VueResource);
|
|
|
|
describe('Conversations', function(){
|
|
|
|
const subscriberId = 123;
|
|
|
|
it('should get all data regarding conversations', function(done){
|
|
let inputString = 'voicemailundefined1';
|
|
let hashedId = crypto.createHash('sha256').update(inputString).digest('base64');
|
|
|
|
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
|
|
}];
|
|
|
|
let data = {
|
|
"_embedded": {
|
|
"ngcp:conversations": innerData
|
|
}
|
|
};
|
|
|
|
let innerDataWithoutLinks = [{
|
|
"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,
|
|
"_id": hashedId
|
|
}];
|
|
|
|
Vue.http.interceptors = [];
|
|
Vue.http.interceptors.unshift((request, next)=>{
|
|
next(request.respondWith(JSON.stringify(data), {
|
|
status: 200
|
|
}));
|
|
});
|
|
getConversations(subscriberId).then((result)=>{
|
|
assert.deepEqual(result, innerDataWithoutLinks);
|
|
done();
|
|
}).catch((err)=>{
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
});
|