Browse Source

16 tests pass, 29 fail, 5 "disclaimer" tests disabled. Number of tests: 45.

1.1.101
Jorg Knobloch 1 year ago
parent
commit
f1992c215c
3 changed files with 9 additions and 7 deletions
  1. +1
    -3
      tests/boilerplate.js
  2. +1
    -1
      tests/mock.js
  3. +7
    -3
      tests/unit/controller.js

+ 1
- 3
tests/boilerplate.js View File

@ -3,8 +3,6 @@
// case the `before` part would probably be part of its constructor
// and this file could be deleted
const os = require('os');
const fs = require('fs');
const pEp = require('../addon/content/modules/pEp');
const pEpAdapter = require('../addon/content/modules/pEpAdapter');
const pEpServer = require('../addon/content/modules/pEpServer');
@ -16,7 +14,7 @@ function getControllerWithDetector(queue, detector) {
const log = new pEpLogger(0);
const server = new pEpServer(log, detector, queue);
const adapter = new pEpAdapter(log, server);
const controller = new pEp([], log, adapter, fs, os);
const controller = new pEp(log, adapter);
pEp.exists = false;
controller.adapter = adapter;
controller.after = () => server.destroyInstance();


+ 1
- 1
tests/mock.js View File

@ -30,7 +30,7 @@ function getQueue() {
queue.expectSent = (expected, z = 0) => {
if (mocked) {
const body = s.getRequest(z).requestBody;
expect(JSON.parse(body)).to.equal(expected);
expect(body).to.equal(JSON.stringify(expected));
}
};
queue.countRequests = () => s.requests.length;


+ 7
- 3
tests/unit/controller.js View File

@ -30,10 +30,12 @@ describe('controller calls', () => {
queue.after();
controller.after();
});
it('get ongoing rating', () => {
it('get outgoing rating', () => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
let result = controller.getOngoingRating("cfg@pep.security", ["cfg@pep.security", "hk@pep.security"]);
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},{"user_id":"","username":"anonymous","address":"hk@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
let result = controller.getOutgoingRating("cfg@pep.security", ["cfg@pep.security", "hk@pep.security"]);
queue.expectSent(
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},{"user_id":"","username":"","address":"hk@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
it('myself', () => {
@ -175,6 +177,7 @@ describe('controller calls', () => {
return result.should.become([]);
});
});
/* Disclaimer functionality was removed for now.
describe('appends the disclaimer, P4TB-131', () => {
it('to unencrypted messages', () => {
controller.setPrefs({
@ -221,4 +224,5 @@ describe('controller calls', () => {
return expect(prom).to.eventually.have.property("longmsg", "body");
});
});
*/
});

Loading…
Cancel
Save