Skip to content

Commit

Permalink
ci(@nestjs) fix unit tests, falling linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Apr 21, 2018
1 parent 3160245 commit 77d4ea7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"precommit": "lint-staged",
"test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec",
"integration-test": "mocha integration/**/*.spec.ts --reporter spec --require ts-node/register",
"lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\"",
"lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
"build": "gulp build && gulp move",
"build:lib": "gulp build --dist bundle",
Expand Down Expand Up @@ -146,7 +146,6 @@
},
"lint-staged": {
"packages/**/*.{ts,json}": [
"npm run lint",
"npm run format",
"git add"
]
Expand Down
9 changes: 9 additions & 0 deletions packages/common/decorators/modules/module.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ModuleMetadata } from '../../interfaces/modules/module-metadata.interfa
import { InvalidModuleConfigException } from './exceptions/invalid-module-config.exception';

const metadataKeys = [
metadata.MODULES,
metadata.IMPORTS,
metadata.EXPORTS,
metadata.COMPONENTS,
Expand Down Expand Up @@ -49,13 +50,21 @@ export function Module(obj: ModuleMetadata): ClassDecorator {
}

function overrideModuleMetadata(moduleMetadata: ModuleMetadata) {
moduleMetadata.modules = moduleMetadata.imports
? moduleMetadata.imports
: moduleMetadata.modules;

moduleMetadata.components = moduleMetadata.providers
? moduleMetadata.providers
: moduleMetadata.components;
}

function showDeprecatedWarnings(moduleMetadata: ModuleMetadata) {
const modulesDeprecatedWarning =
'The "modules" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "imports" key instead.';
const componentsDeprecatetWarning =
'The "components" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "providers" key instead.';

moduleMetadata.modules && deprecate(modulesDeprecatedWarning);
moduleMetadata.components && deprecate(componentsDeprecatetWarning);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ export interface ModuleMetadata {
controllers?: Type<any>[];
providers?: Provider[];
exports?: Array<DynamicModule | string | Provider | any[]>;
/** @deprecated */
modules?: Array<Type<any> | DynamicModule | any[]>;
/** @deprecated */
components?: Provider[];
}
2 changes: 1 addition & 1 deletion packages/core/test/injector/container.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('NestContainer', () => {
describe('extractMetadata', () => {
describe('when module is a dynamic module', () => {
it('should return object with "type" and "dynamicMetadata" property', () => {
const obj = { module: 'test', components: [] };
const obj = { module: 'test', providers: [] };
const { module, ...dynamicMetadata } = obj;
expect(container.extractMetadata(obj as any)).to.be.deep.equal({
type: module,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/injector/injector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ describe('Injector', () => {
let module;
beforeEach(() => {
module = {
components: [],
providers: [],
};
});

Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/scanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ describe('DependenciesScanner', () => {
class TestRoute {}

@Module({
components: [TestComponent],
providers: [TestComponent],
controllers: [TestRoute],
exports: [TestComponent],
})
class AnotherTestModule {}

@Module({
modules: [AnotherTestModule],
components: [TestComponent],
imports: [AnotherTestModule],
providers: [TestComponent],
controllers: [TestRoute],
})
class TestModule {}
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"include": [
"packages/**/*",
"sample/**/*",
"integration/**/*"
],
"exclude": [
Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ordered-imports": [
false
],
"no-implicit-dependencies": false,
"no-unnecessary-initializer": false,
"unified-signatures": false,
"max-line-length": [
Expand Down

0 comments on commit 77d4ea7

Please sign in to comment.