Skip to content

Greco/testing setup #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2022
Merged
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
64 changes: 50 additions & 14 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,56 @@
* To add additional dependencies, add an export statement.
*/

export {
MongoClient,
Database,
Collection,
Bson
export {
MongoClient,
Database,
Collection,
Bson
} from "https://deno.land/x/mongo@v0.29.4/mod.ts";

export type {
CountOptions,
InsertOptions,
UpdateOptions,
FindAndModifyOptions,
DropOptions,
AggregateOptions,
FindOptions,
DeleteOptions,
} from 'https://deno.land/x/mongo@v0.29.4/src/types.ts';

export {
CountOptions,
InsertOptions,
UpdateOptions,
FindAndModifyOptions,
DropOptions,
AggregateOptions,
FindOptions,
DeleteOptions,
} from 'https://deno.land/x/mongo@v0.29.4/src/types.ts';}
afterAll,
afterEach,
beforeAll,
beforeEach,
describe,
it,
} from 'https://deno.land/std@0.138.0/testing/bdd.ts';

export {
assert,
assertAlmostEquals,
assertArrayIncludes,
assertEquals,
assertExists,
assertFalse,
assertInstanceOf,
assertIsError,
assertMatch,
assertNotEquals,
assertNotMatch,
assertNotStrictEquals,
assertObjectMatch,
assertRejects,
assertStrictEquals,
assertStringIncludes,
assertThrows,
equal,
fail,
unimplemented,
unreachable,
} from 'https://deno.land/std@0.138.0/testing/asserts.ts';

import * as dotenv from "https://deno.land/x/dotenv@v3.2.0/mod.ts";
export { dotenv }
11 changes: 3 additions & 8 deletions lib/datatypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,14 @@ export class SchemaDate {
if (typeof convertedDate === 'number') {
if (isNaN(convertedDate)) {
return;
} else {
this.convertedValue = new Date(convertedDate);
}
}
else this.convertedValue = convertedDate;
}

else if (typeof this.value === 'number') {
const convertedDate: number | Date = Date.parse(this.value.toString())
if (typeof convertedDate === 'number') {
if (isNaN(convertedDate)) {
return;
}
}
else this.convertedValue = convertedDate;
this.convertedValue = new Date(this.value);
}

return this.convertedValue;
Expand Down
131 changes: 0 additions & 131 deletions lib/queryfunctions.ts

This file was deleted.

12 changes: 10 additions & 2 deletions lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class Schema {

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

if (schemaObj === undefined) {
throw new Error('Schema requires a valid argument.');
}
this.schemaMap = {};
for (const property in schemaObj) {
if (typeof schemaObj[property] === 'object') {
Expand Down Expand Up @@ -54,7 +57,7 @@ export interface optionsObject {
* @returns An object of class SchemaOptions.
*/

class SchemaOptions {
export class SchemaOptions {

type: any;
required?: boolean;
Expand All @@ -73,7 +76,12 @@ class SchemaOptions {
this.validator = null;
for (const key in options) {
if (key === 'type') {
this.type = dango.types[options[key]];
if (Object.prototype.hasOwnProperty.call(dango.types, options[key])){
this.type = dango.types[options[key]];
}
else {
throw new Error('Specified type is invalid');
}
}
else if (Object.prototype.hasOwnProperty.call(this, key)) {
this[key as keyof optionsObject] = options[key as keyof optionsObject];
Expand Down
Loading