Skip to content

Commit

Permalink
chore: remove tests from build
Browse files Browse the repository at this point in the history
  • Loading branch information
Rmannn committed Apr 27, 2021
1 parent 2e072ba commit e5d969b
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 114 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"typescript": "4.2.4"
},
"scripts": {
"build": "rm -Rf dist && tsc -b",
"build": "rm -Rf dist && tsc -b tsconfig.build.json",
"format": "prettier \"**/*.ts\" --ignore-path ./.prettierignore --write && git status",
"lint": "eslint .",
"doc": "rm -Rf ./docs && typedoc ./src && touch ./docs/.nojekyll",
Expand All @@ -81,7 +81,7 @@
"json",
"ts"
],
"rootDir": "src",
"rootDir": ".",
"testRegex": ".spec.(t|j)s$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
Expand Down
11 changes: 0 additions & 11 deletions src/test/module/entity.index.ts

This file was deleted.

35 changes: 0 additions & 35 deletions src/test/module/entity.relationship.unique.ts

This file was deleted.

File renamed without changes.
56 changes: 35 additions & 21 deletions src/test/module.spec.ts → test/module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import 'reflect-metadata';

import { BadRequestException, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { createNamespace } from 'cls-hooked';
import { MongoClient } from 'mongodb';
import request from 'supertest';

import { DEFAULT_CONNECTION_NAME, MONGO_SESSION_KEY, SESSION_LOADER_NAMESPACE } from '../constants';
import { DataloaderService } from '../dataloader/service';
import { getConnectionToken, getManagerToken, getRepositoryToken, ObjectId } from '../helpers';
import { MongoManager } from '../manager';
import { MongoModule } from '../module';
import { MongoCoreModule } from '../module.core';
import { DEFAULT_CONNECTION_NAME, MONGO_SESSION_KEY, SESSION_LOADER_NAMESPACE } from '../src/constants';
import { DataloaderService } from '../src/dataloader/service';
import { getConnectionToken, getManagerToken, getRepositoryToken, ObjectId } from '../src/helpers';
import { MongoManager } from '../src/manager';
import { MongoModule } from '../src/module';
import { MongoCoreModule } from '../src/module.core';
import {
CascadeType,
getChildrenRelationshipMetadata,
getRelationshipCascadesMetadata,
getRelationshipMetadata,
getRelationshipsCascadesMetadata,
} from '../relationship/metadata';
import { MongoRepository } from '../repository';
CascadeType,
getChildrenRelationshipMetadata,
getRelationshipCascadesMetadata,
getRelationshipMetadata,
getRelationshipsCascadesMetadata,
} from '../src/relationship/metadata';
import { MongoRepository } from '../src/repository';
import { MongoDbModuleTest } from './module';
import { RelationshipEntityLevel1Test } from './module/cascade/level1';
import { RelationshipEntityLevel1WithChildrenTest } from './module/cascade/level1WithChildren';
Expand All @@ -27,10 +29,10 @@ import { EntityChildTest } from './module/child';
import { TestController } from './module/controller';
import { EntityTest, TEST_COLLECTION_NAME } from './module/entity';
import {
ChildDynamicRelationship,
DynamicRelationshipType,
ParentDynamicRelationship1,
ParentDynamicRelationship2,
ChildDynamicRelationship,
DynamicRelationshipType,
ParentDynamicRelationship1,
ParentDynamicRelationship2,
} from './module/entity.dynamic.relationship';
import { EntityWithIndexTest } from './module/entity.index';
import { EntityNestedTest } from './module/entity.nested';
Expand Down Expand Up @@ -513,15 +515,27 @@ describe('Indexes', () => {
.getCollection(EntityUniqueRelationship)
.indexes();

expect(indexes).toHaveLength(3);
expect(indexes[1].unique).toBe(true);
expect(indexes[1].sparse).toBe(true);
expect(indexes[1].key.child).toBe(1);
expect(indexes).toHaveLength(5);

// bar
expect(indexes[1].name).toBe('bar_1');
expect(indexes[1].key.bar).toBe(1);

expect(indexes[2].unique).toBe(true);
expect(indexes[2].sparse).toBe(true);
expect(indexes[2].name).toBe('child_1_child2_1');
expect(indexes[2].key.child).toBe(1);
expect(indexes[2].key.child2).toBe(1);

expect(indexes[3].key.child).toBe(1);
expect(indexes[3].name).toBe(
'EntityUniqueRelationship_child_relationship'
);

expect(indexes[4].key.child2).toBe(1);
expect(indexes[4].name).toBe(
'EntityUniqueRelationship_child2_relationship'
);
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Collection } from '../../../decorators';
import { Entity } from '../../../entity';
import { Collection } from '../../../src/decorators';
import { Entity } from '../../../src/entity';

@Collection('relationshipEntityLevel1Test')
export class RelationshipEntityLevel1Test extends Entity {}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsDefined } from 'class-validator';

import { Collection } from '../../../decorators';
import { Entity } from '../../../entity';
import { ObjectId } from '../../../helpers';
import { IsValidRelationship, Relationship } from '../../../relationship/decorators';
import { CascadeType } from '../../../relationship/metadata';
import { Collection } from '../../../src/decorators';
import { Entity } from '../../../src/entity';
import { ObjectId } from '../../../src/helpers';
import { IsValidRelationship, Relationship } from '../../../src/relationship/decorators';
import { CascadeType } from '../../../src/relationship/metadata';
import { EntityTest } from '../entity';

@Collection('relationshipEntityLevel1WithChildrenTest')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsDefined } from 'class-validator';

import { Collection } from '../../../decorators';
import { Entity } from '../../../entity';
import { ObjectId } from '../../../helpers';
import { IsValidRelationship, Relationship } from '../../../relationship/decorators';
import { CascadeType } from '../../../relationship/metadata';
import { Collection } from '../../../src/decorators';
import { Entity } from '../../../src/entity';
import { ObjectId } from '../../../src/helpers';
import { IsValidRelationship, Relationship } from '../../../src/relationship/decorators';
import { CascadeType } from '../../../src/relationship/metadata';
import { RelationshipEntityLevel1Test } from './level1';

@Collection('relationshipEntityLevel2Test')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsDefined } from 'class-validator';

import { Collection } from '../../../decorators';
import { Entity } from '../../../entity';
import { ObjectId } from '../../../helpers';
import { IsValidRelationship, Relationship } from '../../../relationship/decorators';
import { CascadeType } from '../../../relationship/metadata';
import { Collection } from '../../../src/decorators';
import { Entity } from '../../../src/entity';
import { ObjectId } from '../../../src/helpers';
import { IsValidRelationship, Relationship } from '../../../src/relationship/decorators';
import { CascadeType } from '../../../src/relationship/metadata';
import { RelationshipEntityLevel2Test } from './level2';

@Collection('relationshipEntityLevel3Test')
Expand Down
8 changes: 4 additions & 4 deletions src/test/module/child.ts → test/module/child.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Type } from 'class-transformer';
import { IsDefined, IsOptional, IsString, ValidateNested } from 'class-validator';

import { Collection } from '../../decorators';
import { Entity } from '../../entity';
import { ObjectId } from '../../helpers';
import { IsValidRelationship, Relationship } from '../../relationship/decorators';
import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';
import { ObjectId } from '../../src/helpers';
import { IsValidRelationship, Relationship } from '../../src/relationship/decorators';
import { EntityTest } from './entity';
import { EntityNestedTest } from './entity.nested';
import { EntityRelationship } from './entity.relationship';
Expand Down
8 changes: 4 additions & 4 deletions src/test/module/controller.ts → test/module/controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Controller, Get, Req } from '@nestjs/common';
import { Request } from 'express';

import { DATA_LOADER_NAMESPACE } from '../../constants';
import { InjectManager } from '../../decorators';
import { ObjectId } from '../../helpers';
import { MongoManager } from '../../manager';
import { DATA_LOADER_NAMESPACE } from '../../src/constants';
import { InjectManager } from '../../src/decorators';
import { ObjectId } from '../../src/helpers';
import { MongoManager } from '../../src/manager';
import { EntityTest } from './entity';

@Controller('test')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsIn, IsString } from 'class-validator';
import { ObjectId } from 'mongodb';

import { Collection } from '../../decorators';
import { Entity } from '../../entity';
import { Relationship } from '../../relationship/decorators';
import { CascadeType } from '../../relationship/metadata';
import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';
import { Relationship } from '../../src/relationship/decorators';
import { CascadeType } from '../../src/relationship/metadata';

@Collection('testdynamicparentrelationship1')
export class ParentDynamicRelationship1 extends Entity {
Expand Down
11 changes: 11 additions & 0 deletions test/module/entity.index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';
import { Index } from '../../src/indexes/decorators';

@Collection('testwithindex')
export class EntityWithIndexTest extends Entity {
@Index({
unique: true
})
foo: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IsDefined } from 'class-validator';

import { Collection } from '../../decorators';
import { Entity } from '../../entity';
import { ObjectId } from '../../helpers';
import { Relationship } from '../../relationship/decorators';
import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';
import { ObjectId } from '../../src/helpers';
import { Relationship } from '../../src/relationship/decorators';
import { EntityTest } from './entity';

@Collection('testnested')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IsString } from 'class-validator';
import { ObjectId } from 'mongodb';

import { Collection } from '../../decorators';
import { Entity } from '../../entity';
import { Relationship } from '../../relationship/decorators';
import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';
import { Relationship } from '../../src/relationship/decorators';
import { EntityChildTest } from './child';

@Collection('testrelationship')
Expand Down
32 changes: 32 additions & 0 deletions test/module/entity.relationship.unique.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { IsString } from 'class-validator';
import { ObjectId } from 'mongodb';

import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';
import { Index } from '../../src/indexes/decorators';
import { Relationship } from '../../src/relationship/decorators';
import { EntityChildTest } from './child';

export const TEST_COLLECTION_NAME = 'testuniquerelationship';

@Collection(TEST_COLLECTION_NAME)
export class EntityUniqueRelationship extends Entity {
@IsString()
@Index()
bar: string;

@Relationship({
type: () => EntityChildTest
})
@Index({
key: { child: 1, child2: 1 },
unique: true,
sparse: true
})
child?: ObjectId;

@Relationship({
type: () => EntityChildTest
})
child2?: ObjectId;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from 'class-transformer';

import { Slugify } from '../../decorators';
import { Slugify } from '../../src/decorators';

export class EntitySlugTest {
constructor(firstName: string, lastName: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/module/entity.ts → test/module/entity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IsString } from 'class-validator';

import { Collection } from '../../decorators';
import { Entity } from '../../entity';
import { Collection } from '../../src/decorators';
import { Entity } from '../../src/entity';

export const TEST_COLLECTION_NAME = 'test';

Expand Down
8 changes: 4 additions & 4 deletions src/test/module/index.ts → test/module/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';

import { DataLoaderMiddleware } from '../../dataloader/middleware';
import { InjectRepository } from '../../decorators';
import { MongoModule } from '../../module';
import { MongoRepository } from '../../repository';
import { DataLoaderMiddleware } from '../../src/dataloader/middleware';
import { InjectRepository } from '../../src/decorators';
import { MongoModule } from '../../src/module';
import { MongoRepository } from '../../src/repository';
import { RelationshipEntityLevel1Test } from './cascade/level1';
import { RelationshipEntityLevel1WithChildrenTest } from './cascade/level1WithChildren';
import { RelationshipEntityLevel2Test } from './cascade/level2';
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"]
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strictNullChecks": true
},
"include": ["src/**/*"]
}
// "include": ["src/**/*", "test"]
}

0 comments on commit e5d969b

Please sign in to comment.