aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorTom Harley2018-04-17 17:03:14 +0100
committerTom Harley2018-04-17 17:03:14 +0100
commit44c14c13bdd7ad91a119564622b811cc70147de8 (patch)
tree318420a6bc570bcd3c990d387411e7a205a4e677 /test/unit
parentMerge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff)
parentWorld War Files - changed precondition + filled addSubFileToFolder() function... (diff)
downloadmedicine-44c14c13bdd7ad91a119564622b811cc70147de8.tar.gz
medicine-44c14c13bdd7ad91a119564622b811cc70147de8.zip

Merge branch ‘trh/gets’ of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/project-code into trh/gets

Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/options.unit.test.ts58
-rw-r--r--test/unit/types.unit.test.ts1
2 files changed, 59 insertions, 0 deletions
diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts
index 1925835..fd88ca6 100644
--- a/test/unit/options.unit.test.ts
+++ b/test/unit/options.unit.test.ts
@@ -159,5 +159,63 @@ 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;
+ });
+ it('big bad unit test', () => {
+ /* tslint:disable:align */
+ const matchee = { status: 'success',
+ data: [ { privilege: 'admin', description: 'null', internal: false },
+ { privilege: 'logging',
+ description: 'Allows Post to Log',
+ internal: false } ] };
+ const template = {
+ status: types.string,
+ data: options.optional(types.anything),
+ error: options.optional(types.string),
+ error_description: options.optional(types.string),
+ user_message: options.optional(types.string),
+ error_data: options.optional(types.anything)
+ };
+ /* tslint:enable:align */
+
+ options.match(template)(matchee).should.be.true;
+ });
+ it('bigger badder unit test', () => {
+ /* tslint:disable:align */
+ const matchee = [ { project_name: 'mocky',
+ users: [{ username: 'uname', access_level: 'admin'}],
+ public_metadata: { creation_date: '2018-04-14T17:13:44.291Z' },
+ private_metadata: {},
+ admin_metadata: {} } ];
+ const template = types.array({
+ project_name: types.string,
+ users: types.array({
+ username: types.string,
+ access_level: types.string
+ }),
+ public_metadata: types.anything,
+ private_metadata: options.optional(types.anything),
+ admin_metadata: options.optional(types.anything)
+ });
+ /* tslint:enable:align */
+
+ options.match(template)(matchee).should.be.true;
+ });
+ it.only('Matching Arrays', () => {
+ /* tslint:disable:align */
+ const matchee: any = ['ss'];
+ const template: any = types.array;
+ /* tslint:enable:align */
+
+ 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;