Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Commit d96b65e

Browse files
committed
refactor(di): rewrite di
1 parent 8161260 commit d96b65e

17 files changed

+378
-333
lines changed

packages/di/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"url": "https://github.com/LeetCode-OpenSource/asuka/issues"
2727
},
2828
"dependencies": {
29-
"injection-js": "^2.2.2",
3029
"tslib": "^1.10.0"
3130
},
3231
"optionalDependencies": {

packages/di/src/__tests__/context.spec.tsx

+5-11
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import test from 'ava'
66

77
import { InjectionProvidersContext, InjectableContext, useInstance } from '../context'
88
import { Injectable } from '../injectable'
9-
import { rootInjectableFactory } from '../injectable-factory-instance'
10-
import { ValueProvider } from 'injection-js'
119

1210
function render(component: React.ReactElement) {
1311
return create(<InjectableContext>{component}</InjectableContext>)
@@ -25,10 +23,6 @@ function inject() {
2523
return { Module, Service }
2624
}
2725

28-
test.beforeEach(() => {
29-
rootInjectableFactory.reset()
30-
})
31-
3226
test('should getInstance', (t) => {
3327
const { Module, Service } = inject()
3428
const TestComponent = () => {
@@ -42,7 +36,7 @@ test('should getInstance', (t) => {
4236

4337
test('should override provider', (t) => {
4438
const { Module, Service } = inject()
45-
const mockService: ValueProvider = {
39+
const mockService = {
4640
provide: Service,
4741
useValue: 1,
4842
}
@@ -61,11 +55,11 @@ test('should override provider', (t) => {
6155

6256
test('Muti providers context', (t) => {
6357
const { Module, Service } = inject()
64-
const mockService1: ValueProvider = {
58+
const mockService1 = {
6559
provide: Service,
6660
useValue: 1,
6761
}
68-
const mockService2: ValueProvider = {
62+
const mockService2 = {
6963
provide: Service,
7064
useValue: 2,
7165
}
@@ -95,11 +89,11 @@ test('Muti providers context', (t) => {
9589

9690
test('Nested providers', (t) => {
9791
const { Module, Service } = inject()
98-
const mockService1: ValueProvider = {
92+
const mockService1 = {
9993
provide: Service,
10094
useValue: 1,
10195
}
102-
const mockService2: ValueProvider = {
96+
const mockService2 = {
10397
provide: Service,
10498
useValue: 2,
10599
}

0 commit comments

Comments
 (0)