Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

fix tests #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ jobs:
yarn add cp-translations@staging
fi
- run:
name: Tests
name: Unit Tests
command: yarn test
- run:
name: Test joi
command: yarn test-joi
- run:
name: Test skeleton
command: yarn test-skeleton
deploy:
working_directory: ~/cp-organisations-service
docker:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
isMemberOf: {
role: 'basic-user',
},
};
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
"main": "index.js",
"scripts": {
"test": "lab lib -P spec -r console -v -m 3000 -c -t 80",
"testjoi": "lab test/joi.test.js -r console -v -m 3000 -c -t 80",
"testskeleton": "lab test/skeleton.js -r console -v -m 3000 -c -t 80",
"test-joi": "lab test/joi.test.js -r console -v -m 3000",
"test-skeleton": "lab test/skeleton.js -r console -v -m 3000 -c -t 80",
"lint": "eslint .",
"fix": "eslint . --fix",
"start": "node index.js",
"dev": "nodemon index.js"
},
"keywords": [
"organisation",
"coderdojo"
],
"keywords": ["organisation", "coderdojo"],
"author": "Coderdojo",
"license": "ISC",
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions test/skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('../network')(seneca);
const _ = require('lodash');
const flat = require('flat');

const service = 'cd-eventbrite';
const service = 'cd-organisations';
// ENTITIES
const entities = {};
entities.userOrg = require('../lib/organisations/entities/userOrg.js').bind(seneca)();
Expand Down Expand Up @@ -70,23 +70,23 @@ describe('cp-organisations-service-controller', () => {
// // VALIDATION
// No need to validate them all, we just want to verify the bootloader (/lib/index)
it('should validate entities acts with joi', (done) => {
seneca.act({ role: 'cd-organisations', entity: 'event', cmd: 'get', id: {} }, (err, app) => {
seneca.act({ role: 'cd-organisations', entity: 'org', cmd: 'get'}, (err, app) => {
expect(err.code).to.be.equal('act_invalid_msg');
done();
});
});
//
it('should validate entities acts while promised with joi', (done) => {
const app = seneca.export('cd-organisations/acts').event;
app.get({ id: {} })
const app = seneca.export('cd-organisations/acts').org;
app.get({ org: undefined})
Copy link
Contributor

@Wardormeur Wardormeur Dec 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get takes an id : https://github.com/CoderDojo/cp-organisations-service/blob/master/lib/organisations/entities/org.js#L21
It's not "wrong" because we're testing a falsy scenario but still

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you told me to put in org: undefined

.catch((err) => {
expect(err.code).to.be.equal('act_invalid_msg');
done();
});
});
//
it('should validate controllers acts with joi', (done) => {
seneca.act({ role: 'cd-organisations', ctrl: 'auth', cmd: 'authorize', dojoId: {} }, (err, app) => {
seneca.act({ role: 'cd-organisations', ctrl: 'userOrg', cmd: 'create', userOrg: {} }, (err, app) => {
expect(err.code).to.be.equal('act_invalid_msg');
done();
});
Expand Down