-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Goodluckhf/develop
Рефакторинг и валидация манифеста
- Loading branch information
Showing
33 changed files
with
602 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { ManifestInterface } from './manifest.interface'; | ||
import { Token } from './internal-types'; | ||
import { ManifestInterface as publicManifestInterface } from './public-interfaces/manifest.interface'; | ||
|
||
export interface ContainerInterface { | ||
loadManifests(manifests: ManifestInterface[]); | ||
loadManifests(manifests: publicManifestInterface[]); | ||
compile(); | ||
get(moduleName: string, token: Token); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,21 @@ | ||
import 'reflect-metadata'; | ||
import { Container } from './container'; | ||
import { Module } from './module'; | ||
import { AlreadyCompiledError } from './errors/already-compiled.error'; | ||
|
||
class TestServiceA {} | ||
class TestServiceB { | ||
constructor(testServiceA) { | ||
describe('IoC container', function() { | ||
beforeEach(() => { | ||
// @ts-ignore | ||
this.testServiceA = testServiceA; | ||
} | ||
} | ||
|
||
describe('IoC container', () => { | ||
it('should parse manifest to module', () => { | ||
const container = new Container(); | ||
const diManifest = { | ||
moduleName: 'tesModule', | ||
providers: [ | ||
{ | ||
token: 'testServiceA', | ||
useClass: TestServiceA, | ||
}, | ||
], | ||
}; | ||
|
||
container.loadManifests([diManifest]); | ||
// @ts-ignore | ||
expect(container.modules.size).toEqual(1); | ||
// @ts-ignore | ||
expect([...container.modules.values()][0]).toBeInstanceOf(Module); | ||
this.container = new Container({}, {}); | ||
}); | ||
|
||
it('Should throw error if has already compiled', () => { | ||
const container = new Container(); | ||
const diManifest = { | ||
moduleName: 'tesModule', | ||
providers: [ | ||
{ | ||
token: 'testServiceA', | ||
useClass: TestServiceA, | ||
}, | ||
], | ||
}; | ||
container.loadManifests([diManifest]); | ||
container.compile(); | ||
expect(() => { | ||
container.compile(); | ||
}).toThrow(AlreadyCompiledError); | ||
expect.assertions(1); | ||
this.container.applyPublicProviders = () => {}; | ||
this.container.compile(); | ||
try { | ||
this.container.compile(); | ||
} catch (e) { | ||
expect(e).toBeInstanceOf(AlreadyCompiledError); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.