Split tests between libtextsecure and main
This commit is contained in:
parent
8ad1a38b5b
commit
899d756469
16 changed files with 16397 additions and 10 deletions
42
libtextsecure/test/fake_api.js
Normal file
42
libtextsecure/test/fake_api.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* vim: ts=4:sw=4
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var getKeysForNumberMap = {};
|
||||
textsecure.api.getKeysForNumber = function(number, deviceId) {
|
||||
var res = getKeysForNumberMap[number];
|
||||
if (res !== undefined) {
|
||||
delete getKeysForNumberMap[number];
|
||||
return Promise.resolve(res);
|
||||
} else
|
||||
throw new Error("getKeysForNumber of unknown/used number");
|
||||
}
|
||||
|
||||
var messagesSentMap = {};
|
||||
textsecure.api.sendMessages = function(destination, messageArray) {
|
||||
for (i in messageArray) {
|
||||
var msg = messageArray[i];
|
||||
if ((msg.type != 1 && msg.type != 3) ||
|
||||
msg.destinationDeviceId === undefined ||
|
||||
msg.destinationRegistrationId === undefined ||
|
||||
msg.body === undefined ||
|
||||
msg.timestamp == undefined ||
|
||||
msg.relay !== undefined ||
|
||||
msg.destination !== undefined)
|
||||
throw new Error("Invalid message");
|
||||
|
||||
messagesSentMap[destination + "." + messageArray[i].destinationDeviceId] = msg;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue