diff options
| author | jw255 | 2018-04-13 21:12:53 +0100 |
|---|---|---|
| committer | jw255 | 2018-04-13 21:12:53 +0100 |
| commit | 9c0ff9a0b7d73e5e2a12c4f87d1aa586c59adec9 (patch) | |
| tree | 4ec4ff8eb5fdc17041ae5b8e6bf9158a2eebbe81 /test | |
| parent | fixed template matching in test suite (diff) | |
| download | medicine-9c0ff9a0b7d73e5e2a12c4f87d1aa586c59adec9.tar.gz medicine-9c0ff9a0b7d73e5e2a12c4f87d1aa586c59adec9.zip | |
only 12 failing tests :D
Diffstat (limited to 'test')
| -rw-r--r-- | test/integration/protocol.routes.test.ts | 19 | ||||
| -rw-r--r-- | test/test-db.ts | 4 | ||||
| -rw-r--r-- | test/unit/options.unit.test.ts | 10 | ||||
| -rw-r--r-- | test/unit/types.unit.test.ts | 1 |
4 files changed, 29 insertions, 5 deletions
diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts index ebe18c2..7f9f3e7 100644 --- a/test/integration/protocol.routes.test.ts +++ b/test/integration/protocol.routes.test.ts @@ -10,6 +10,7 @@ const expect: Chai.ExpectStatic = chai.expect; import { Credentials, Database, addUser, initDB, resetDB, Projec, addProjec, Filee, addFilee } from '../test-db'; import { default as User } from '../../src/db/model/User'; +import * as fs from 'fs'; // Chai-http must be imported this way: // tslint:disable-next-line:no-var-requires no-require-imports @@ -153,7 +154,7 @@ describe('routes : protocol', () => { types.boolean ]) }), 200], - ['post', '/properties', null, 200], + ['post', '/properties?action=update', null, 200], ['get', '/user_privileges', array({ privilege: types.string, description: types.string, @@ -231,7 +232,7 @@ describe('routes : protocol', () => { data: optional(types.anything) }, 200], ['get', '/projects/mocky/files/example/path', null, 200], - ['post', '/projects/mocky/files/mockyfile2', null, 200], + ['post', '/projects/mocky/files/some_file?action=overwrite', {}, 200], ['get', '/projects/mocky/files_by_id/file1', null, 200] ]; @@ -257,11 +258,19 @@ describe('routes : protocol', () => { forEach(completeProtocol).it( '%s %s should have a status %4$d', (method: string, path: string, temp: Template, resCode: number) => { - const request: ChaiHttp.Request = method === 'get' + const request: any = method === 'get' ? chai.request(app).get(base + path) : chai.request(app).post(base + path); + /*if (path.includes('/projects/mocky/files/some_file')) { + fs.createReadStream('test/mockUI/ui.html').pipe( + request); + console.log("tasdasdas") + }*/ request.set('Authorization', `Bearer ${token}`); return request.then((res: ChaiHttp.Response) => { + if (path.includes('/projects/mocky/files/some_file')) { + console.log("something") + } expect(res).to.have.status(resCode); }); }); @@ -273,6 +282,10 @@ describe('routes : protocol', () => { : chai.request(app).post(base + path); request.set('Authorization', `Bearer ${token}`); return request.then((res: ChaiHttp.Response) => { + if(path == '/properties' || path == '/current_user'){ + //console.log(res.body) + //console.log(responseTemplate); + } expect(match(responseTemplate)(res.body)).to.be.true; }); }); diff --git a/test/test-db.ts b/test/test-db.ts index 40ae438..ef980c5 100644 --- a/test/test-db.ts +++ b/test/test-db.ts @@ -112,9 +112,9 @@ export const addFilee: (database: Database, user: Credentials) => path: 'example/path', uuid: 'file1', creator: user, - type: "generic" + type: 'generic' }; await new File(mockFile).save(); return mockFile; -};
\ No newline at end of file +}; diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts index 1925835..29000de 100644 --- a/test/unit/options.unit.test.ts +++ b/test/unit/options.unit.test.ts @@ -159,5 +159,15 @@ describe('Matching:', () => { }; options.match(template, matchee).should.be.false; }); + it('accepts optional matches', () => { + const template = { + a: options.optional(types.array), + b: options.optional(types.anything) + }; + const matchee = { + b: [] + }; + options.match(template)(matchee).should.be.true; + }); }); }); diff --git a/test/unit/types.unit.test.ts b/test/unit/types.unit.test.ts index ad0f99c..f18d5a1 100644 --- a/test/unit/types.unit.test.ts +++ b/test/unit/types.unit.test.ts @@ -30,6 +30,7 @@ describe('Type Checking:', () => { types.anything(1).should.be.true; types.anything('string').should.be.true; types.anything(false).should.be.true; + types.anything([]).should.be.true; }); it('accepts null', () => { types.anything(null).should.be.true; |
