2
2
"use strict" ;
3
3
4
4
import * as decoratorsLib from "../../decorators" ;
5
- import * as yokLib from "../../yok" ;
5
+ import { Yok } from "../../yok" ;
6
6
import { assert } from "chai" ;
7
7
import Future = require( "fibers/future" ) ;
8
8
9
- let originalInjector :any = { } ;
10
- _ . extend ( originalInjector , $injector ) ;
11
-
12
9
describe ( "decorators" , ( ) => {
13
10
afterEach ( ( ) => {
14
- $injector = originalInjector ;
15
- // Due to bug in lodash's extend method, manually set publicApi to the initial object.
16
- $injector . publicApi = { __modules__ : { } } ;
11
+ $injector = new Yok ( ) ;
17
12
} ) ;
18
13
19
14
describe ( "exportedPromise" , ( ) => {
@@ -37,7 +32,7 @@ describe("decorators", () => {
37
32
} ) ;
38
33
39
34
it ( "returns Promise" , ( ) => {
40
- $injector = new yokLib . Yok ( ) ;
35
+ $injector = new Yok ( ) ;
41
36
let expectedResult = "result" ;
42
37
$injector . register ( "moduleName" , { propertyName : ( ) => { return expectedResult ; } } ) ;
43
38
assert . deepEqual ( $injector . publicApi . __modules__ [ "moduleName" ] , undefined ) ;
@@ -52,7 +47,7 @@ describe("decorators", () => {
52
47
} ) ;
53
48
54
49
it ( "returns Promise, which is resolved to correct value (function without arguments)" , ( ) => {
55
- $injector = new yokLib . Yok ( ) ;
50
+ $injector = new Yok ( ) ;
56
51
let expectedResult = "result" ;
57
52
$injector . register ( "moduleName" , { propertyName : ( ) => { return expectedResult ; } } ) ;
58
53
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -65,7 +60,7 @@ describe("decorators", () => {
65
60
} ) ;
66
61
67
62
it ( "returns Promise, which is resolved to correct value (function with arguments)" , ( ) => {
68
- $injector = new yokLib . Yok ( ) ;
63
+ $injector = new Yok ( ) ;
69
64
let expectedArgs = [ "result" , "result1" , "result2" ] ;
70
65
$injector . register ( "moduleName" , { propertyName : ( functionArgs : string [ ] ) => { return functionArgs ; } } ) ;
71
66
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -78,7 +73,7 @@ describe("decorators", () => {
78
73
} ) ;
79
74
80
75
it ( "returns Promise, which is resolved to correct value (function returning IFuture without arguments)" , ( ) => {
81
- $injector = new yokLib . Yok ( ) ;
76
+ $injector = new Yok ( ) ;
82
77
let expectedResult = "result" ;
83
78
$injector . register ( "moduleName" , { propertyName : ( ) => Future . fromResult ( expectedResult ) } ) ;
84
79
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -91,7 +86,7 @@ describe("decorators", () => {
91
86
} ) ;
92
87
93
88
it ( "returns Promise, which is resolved to correct value (function returning IFuture with arguments)" , ( ) => {
94
- $injector = new yokLib . Yok ( ) ;
89
+ $injector = new Yok ( ) ;
95
90
let expectedArgs = [ "result" , "result1" , "result2" ] ;
96
91
$injector . register ( "moduleName" , { propertyName : ( args : string [ ] ) => Future . fromResult ( args ) } ) ;
97
92
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -104,7 +99,7 @@ describe("decorators", () => {
104
99
} ) ;
105
100
106
101
it ( "rejects Promise, which is resolved to correct error (function without arguments throws)" , ( ) => {
107
- $injector = new yokLib . Yok ( ) ;
102
+ $injector = new Yok ( ) ;
108
103
let expectedError = new Error ( "Test msg" ) ;
109
104
$injector . register ( "moduleName" , { propertyName : ( ) => { throw expectedError ; } } ) ;
110
105
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -119,7 +114,7 @@ describe("decorators", () => {
119
114
} ) ;
120
115
121
116
it ( "rejects Promise, which is resolved to correct error (function returning IFuture without arguments throws)" , ( ) => {
122
- $injector = new yokLib . Yok ( ) ;
117
+ $injector = new Yok ( ) ;
123
118
let expectedError = new Error ( "Test msg" ) ;
124
119
$injector . register ( "moduleName" , { propertyName : ( ) => { return ( ( ) => { throw expectedError ; } ) . future < void > ( ) ( ) ; } } ) ;
125
120
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -135,7 +130,7 @@ describe("decorators", () => {
135
130
} ) ;
136
131
137
132
it ( "returns Promises, which are resolved to correct value (function returning IFuture<T>[] without arguments)" , ( ) => {
138
- $injector = new yokLib . Yok ( ) ;
133
+ $injector = new Yok ( ) ;
139
134
let expectedResults = [ "result1" , "result2" , "result3" ] ;
140
135
$injector . register ( "moduleName" , { propertyName : ( ) => _ . map ( expectedResults , expectedResult => Future . fromResult ( expectedResult ) ) } ) ;
141
136
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -148,7 +143,7 @@ describe("decorators", () => {
148
143
} ) ;
149
144
150
145
it ( "rejects Promises, which are resolved to correct error (function returning IFuture<T>[] without arguments throws)" , ( ) => {
151
- $injector = new yokLib . Yok ( ) ;
146
+ $injector = new Yok ( ) ;
152
147
let expectedErrors = [ new Error ( "result1" ) , new Error ( "result2" ) , new Error ( "result3" ) ] ;
153
148
$injector . register ( "moduleName" , { propertyName : ( ) => _ . map ( expectedErrors , expectedError => { return ( ( ) => { throw expectedError ; } ) . future < void > ( ) ( ) ; } ) } ) ;
154
149
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
@@ -164,7 +159,7 @@ describe("decorators", () => {
164
159
} ) ;
165
160
166
161
it ( "rejects only Promises which throw, resolves the others correctly (function returning IFuture<T>[] without arguments)" , ( ) => {
167
- $injector = new yokLib . Yok ( ) ;
162
+ $injector = new Yok ( ) ;
168
163
let expectedResults : any [ ] = [ "result1" , new Error ( "result2" ) ] ;
169
164
$injector . register ( "moduleName" , { propertyName : ( ) => _ . map ( expectedResults , expectedResult => Future . fromResult ( expectedResult ) ) } ) ;
170
165
let promisifiedResultFunction : any = decoratorsLib . exportedPromise ( "moduleName" ) ;
0 commit comments