test.injectors.ts

import { appModule, Module, Injector, InjectorFactory} from './../src/test' /* ---- MOCKS ---- */ @Module({ type: 'test', deps: [] }) export class TestModule extends Injector { superTest() { return 'super test' } } @Module({ type: 'test2', deps: ['test'] }) export class Test2Module extends Injector { constructor(private test: TestModule) { super() } tester() { return this.test.superTest() } } const Test3 = InjectorFactory.create('test', [], () => { return { superTest() { return 'super test' } } }) /* ---- TESTS ---- */ describe('Test injection module', () => { test('Inject in disorder', () => { const injectorTree = appModule([Test2Module, TestModule]) const tester = injectorTree['test2']['tester']() expect(tester).toEqual('super test') }) test('Inject non module injector', () => { const injectorTree = appModule([Test3, Test2Module]) const tester = injectorTree['test2']['tester']() expect(tester).toEqual('super test') }) })
Tests for the injectors

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.