Browse Source

Fix get_outgoing_message_rating_feature.js. 24 tests pass, 21 fail.

1.1.101
Jorg Knobloch 1 year ago
parent
commit
6f1f4e62cb
2 changed files with 140 additions and 124 deletions
  1. +0
    -124
      tests/features/get_ongoing_message_rating_feature.js
  2. +140
    -0
      tests/features/get_outgoing_message_rating_feature.js

+ 0
- 124
tests/features/get_ongoing_message_rating_feature.js View File

@ -1,124 +0,0 @@
/* eslint-disable no-console */
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
describe('pEp Get Ongoing Message Rating Feature', () => {
let getController = require('../boilerplate').getController;
let getQueue = require('../mock').getQueue;
let queue, pEpController;
before(() => {
queue = getQueue();
pEpController = getController(queue);
});
after(() => {
queue.after();
pEpController.after();
});
describe('Perfect scenario', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", ["cfg@pep.security"]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
describe('Perfect scenario 2', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", ["hk@pep.security"]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
describe('Perfect scenario 3', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", [{address: "hk@pep.security", username: ""}]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
describe('Empty to', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", [{}]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(0);
});
});
describe('Empty to', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", [{address: "", username: "test"}]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(0);
});
});
describe('With 2 receviers', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", ["cfg@pep.security", "hk@pep.security"]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
describe('With none receviers', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", []);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(0);
});
});
describe('With none receviers', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOngoingRating("cfg@pep.security", ["randomguy@randomdomain.com"]);
});
it('should return a Object', () => {
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":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
});

+ 140
- 0
tests/features/get_outgoing_message_rating_feature.js View File

@ -0,0 +1,140 @@
/* eslint-disable no-console */
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
describe('pEp Get Outgoing Message Rating Feature', () => {
let getController = require('../boilerplate').getController;
let getQueue = require('../mock').getQueue;
let queue, pEpController;
before(() => {
queue = getQueue();
pEpController = getController(queue);
});
after(() => {
queue.after();
pEpController.after();
});
describe('Perfect scenario', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", ["cfg@pep.security"]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
describe('Perfect scenario 2', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", ["hk@pep.security"]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
describe('Perfect scenario 3', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", [{address: "hk@pep.security", username: ""}]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
describe('Empty to (1)', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", [{}]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
describe('Empty to (2)', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", [{address: "", username: "test"}]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
describe('With 2 receviers', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", ["cfg@pep.security", "hk@pep.security"]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
describe('With none receviers (1)', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", []);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(0);
});
});
describe('With none receviers (2)', () => {
let result = "initial value";
before(() => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
result = pEpController.getOutgoingRating("cfg@pep.security", ["randomguy@randomdomain.com"]);
});
it('should return a Object', () => {
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":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"}
);
return result.should.become(3);
});
});
});

Loading…
Cancel
Save