Skip to content

Commit

Permalink
chore: update dependencies, bump version to 0.11.0
Browse files Browse the repository at this point in the history
breaking changes: Migrate to class-transformer 0.4.0
  • Loading branch information
Rmannn committed Apr 12, 2021
1 parent 5636d90 commit 26e8c49
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 321 deletions.
6 changes: 1 addition & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"project": "./tsconfig.json"
},
"ignorePatterns": ["typedoc.js", "docs/*"],
"extends": [
"standard-with-typescript",
"prettier",
"prettier/@typescript-eslint"
],
"extends": ["standard-with-typescript", "prettier"],
"root": true,
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
Expand Down
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nestjs-mongo",
"version": "0.10.7",
"version": "0.11.0",
"description": "A NestJS module that provide a simple mongodb orm like",
"keywords": [
"nestjs",
Expand All @@ -21,48 +21,48 @@
"class-validator": "^0.13.1"
},
"dependencies": {
"class-transformer": "0.3.2",
"class-transformer": "0.4.0",
"cls-hooked": "4.2.2",
"dataloader": "2.0.0",
"debug": "4.3.1",
"global": "4.4.0",
"lodash": "4.17.20",
"mongodb": "3.6.3",
"slugify": "1.4.6",
"lodash": "4.17.21",
"mongodb": "3.6.6",
"slugify": "1.5.0",
"uuid": "8.3.2"
},
"devDependencies": {
"@nestjs/common": "7.6.5",
"@nestjs/core": "7.6.5",
"@nestjs/platform-express": "7.6.5",
"@nestjs/testing": "7.6.5",
"@types/cls-hooked": "4.3.1",
"@nestjs/common": "7.6.15",
"@nestjs/core": "7.6.15",
"@nestjs/testing": "7.6.15",
"@nestjs/platform-express": "7.6.15",
"@types/cls-hooked": "4.3.3",
"@types/debug": "4.1.5",
"@types/jest": "26.0.20",
"@types/jest": "26.0.22",
"@types/lodash": "4.14.168",
"@types/mongodb": "3.6.3",
"@types/supertest": "2.0.10",
"@typescript-eslint/eslint-plugin": "4.14.0",
"@typescript-eslint/parser": "4.14.0",
"@types/mongodb": "3.6.12",
"@types/supertest": "2.0.11",
"@typescript-eslint/eslint-plugin": "4.21.0",
"@typescript-eslint/parser": "4.21.0",
"class-validator": "0.13.1",
"eslint": "7.18.0",
"eslint-config-prettier": "7.2.0",
"eslint-config-standard-with-typescript": "19.0.1",
"eslint": "7.24.0",
"eslint-config-prettier": "8.1.0",
"eslint-config-standard-with-typescript": "20.0.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prefer-arrow": "1.2.2",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "5.0.0",
"jest": "26.6.3",
"prettier": "2.2.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.6.3",
"supertest": "6.1.1",
"ts-jest": "26.4.4",
"rxjs": "6.6.7",
"supertest": "6.1.3",
"ts-jest": "26.5.4",
"ts-node": "9.1.1",
"tsconfig-paths": "3.9.0",
"typedoc": "0.20.16",
"typescript": "4.0.5"
"typedoc": "0.20.35",
"typescript": "4.2.4"
},
"scripts": {
"build": "rm -Rf dist && tsc -b",
Expand Down
30 changes: 30 additions & 0 deletions src/test/decorators.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ObjectId } from 'bson';
import { plainToClass } from 'class-transformer';

import { EntityTest } from './module/entity';
import { EntityRelationship } from './module/entity.relationship';
import { EntitySlugTest } from './module/entity.slug';

describe('Slug decorator', () => {
Expand All @@ -12,3 +15,30 @@ describe('Slug decorator', () => {
expect(target.slug2).toEqual('john-smith');
});
});

describe('TypeObjectId decorator', () => {
test('should keep ObjectId on plainToClass', () => {
const target = plainToClass(EntityTest, {
_id: new ObjectId()
});
expect(target._id).toBeInstanceOf(ObjectId);
});
test('should transform string to ObjectId on plainToClass', () => {
const target = plainToClass(EntityTest, {
_id: new ObjectId().toHexString()
});
expect(target._id).toBeInstanceOf(ObjectId);
});
test('should keep ObjectId on plainToClass with relationship type', () => {
const target = plainToClass(EntityRelationship, {
relationshipAsReference: new ObjectId()
});
expect(target.relationshipAsReference).toBeInstanceOf(ObjectId);
});
test('should transform string to ObjectId on plainToClass with relationship type', () => {
const target = plainToClass(EntityRelationship, {
relationshipAsReference: new ObjectId().toHexString()
});
expect(target.relationshipAsReference).toBeInstanceOf(ObjectId);
});
});
Loading

0 comments on commit 26e8c49

Please sign in to comment.