Skip to content

Commit 7b732c2

Browse files
authored
Merge pull request #30 from oslabs-beta/greco/testing-setup
Greco/testing setup
2 parents fb5401b + 845827e commit 7b732c2

File tree

7 files changed

+2078
-155
lines changed

7 files changed

+2078
-155
lines changed

deps.ts

+50-14
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,56 @@
33
* To add additional dependencies, add an export statement.
44
*/
55

6-
export {
7-
MongoClient,
8-
Database,
9-
Collection,
10-
Bson
6+
export {
7+
MongoClient,
8+
Database,
9+
Collection,
10+
Bson
1111
} from "https://deno.land/x/mongo@v0.29.4/mod.ts";
1212

13+
export type {
14+
CountOptions,
15+
InsertOptions,
16+
UpdateOptions,
17+
FindAndModifyOptions,
18+
DropOptions,
19+
AggregateOptions,
20+
FindOptions,
21+
DeleteOptions,
22+
} from 'https://deno.land/x/mongo@v0.29.4/src/types.ts';
23+
1324
export {
14-
CountOptions,
15-
InsertOptions,
16-
UpdateOptions,
17-
FindAndModifyOptions,
18-
DropOptions,
19-
AggregateOptions,
20-
FindOptions,
21-
DeleteOptions,
22-
} from 'https://deno.land/x/mongo@v0.29.4/src/types.ts';}
25+
afterAll,
26+
afterEach,
27+
beforeAll,
28+
beforeEach,
29+
describe,
30+
it,
31+
} from 'https://deno.land/std@0.138.0/testing/bdd.ts';
32+
33+
export {
34+
assert,
35+
assertAlmostEquals,
36+
assertArrayIncludes,
37+
assertEquals,
38+
assertExists,
39+
assertFalse,
40+
assertInstanceOf,
41+
assertIsError,
42+
assertMatch,
43+
assertNotEquals,
44+
assertNotMatch,
45+
assertNotStrictEquals,
46+
assertObjectMatch,
47+
assertRejects,
48+
assertStrictEquals,
49+
assertStringIncludes,
50+
assertThrows,
51+
equal,
52+
fail,
53+
unimplemented,
54+
unreachable,
55+
} from 'https://deno.land/std@0.138.0/testing/asserts.ts';
56+
57+
import * as dotenv from "https://deno.land/x/dotenv@v3.2.0/mod.ts";
58+
export { dotenv }

lib/datatypes.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -419,19 +419,14 @@ export class SchemaDate {
419419
if (typeof convertedDate === 'number') {
420420
if (isNaN(convertedDate)) {
421421
return;
422+
} else {
423+
this.convertedValue = new Date(convertedDate);
422424
}
423425
}
424-
else this.convertedValue = convertedDate;
425426
}
426427

427428
else if (typeof this.value === 'number') {
428-
const convertedDate: number | Date = Date.parse(this.value.toString())
429-
if (typeof convertedDate === 'number') {
430-
if (isNaN(convertedDate)) {
431-
return;
432-
}
433-
}
434-
else this.convertedValue = convertedDate;
429+
this.convertedValue = new Date(this.value);
435430
}
436431

437432
return this.convertedValue;

lib/queryfunctions.ts

-131
This file was deleted.

lib/schema.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export class Schema {
2626

2727
constructor(schemaObj: Record<string, any>) {
2828

29+
if (schemaObj === undefined) {
30+
throw new Error('Schema requires a valid argument.');
31+
}
2932
this.schemaMap = {};
3033
for (const property in schemaObj) {
3134
if (typeof schemaObj[property] === 'object') {
@@ -54,7 +57,7 @@ export interface optionsObject {
5457
* @returns An object of class SchemaOptions.
5558
*/
5659

57-
class SchemaOptions {
60+
export class SchemaOptions {
5861

5962
type: any;
6063
required?: boolean;
@@ -73,7 +76,12 @@ class SchemaOptions {
7376
this.validator = null;
7477
for (const key in options) {
7578
if (key === 'type') {
76-
this.type = dango.types[options[key]];
79+
if (Object.prototype.hasOwnProperty.call(dango.types, options[key])){
80+
this.type = dango.types[options[key]];
81+
}
82+
else {
83+
throw new Error('Specified type is invalid');
84+
}
7785
}
7886
else if (Object.prototype.hasOwnProperty.call(this, key)) {
7987
this[key as keyof optionsObject] = options[key as keyof optionsObject];

0 commit comments

Comments
 (0)