@@ -3,15 +3,16 @@ import { Yok } from "../../lib/common/yok";
3
3
import { LoggingLevels } from "../../lib/common/mobile/logging-levels" ;
4
4
import * as assert from "assert" ;
5
5
6
- function createTestInjector ( ) : IInjector {
6
+ function createTestInjector ( projectName : string ) : IInjector {
7
7
const testInjector = new Yok ( ) ;
8
8
testInjector . register ( "loggingLevels" , LoggingLevels ) ;
9
9
testInjector . register ( "fs" , {
10
10
exists : ( ) => false
11
11
} ) ;
12
12
testInjector . register ( "projectData" , {
13
13
initializeProjectData : ( ) => { /* empty */ } ,
14
- projectDir : "test"
14
+ projectDir : "test" ,
15
+ projectName : projectName
15
16
} ) ;
16
17
17
18
return testInjector ;
@@ -24,6 +25,7 @@ describe("iOSLogFilter", () => {
24
25
const testData = [
25
26
{
26
27
version : 9 ,
28
+ projectName : "NativeScript250" ,
27
29
originalDataArr : [
28
30
"May 24 15:54:38 Dragons-iPhone backboardd(BaseBoard)[62] <Error>: Unable to bootstrap_look_up port with name .gsEvents: unknown error code (1102)" ,
29
31
"May 24 15:54:51 Dragons-iPhone locationd[67] <Notice>: Client com.apple.springboard disconnected" ,
@@ -45,9 +47,10 @@ describe("iOSLogFilter", () => {
45
47
null ,
46
48
null ,
47
49
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION" ,
48
- "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
50
+ null ,
49
51
""
50
52
] ,
53
+ simProjectName : "TestApp" ,
51
54
simulator : [
52
55
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
53
56
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
@@ -60,6 +63,7 @@ describe("iOSLogFilter", () => {
60
63
]
61
64
} , {
62
65
version : 10 ,
66
+ projectName : "NativeScript250" ,
63
67
originalDataArr : [
64
68
"May 24 15:54:52 Dragons-iPhone apsd(PersistentConnection)[90] <Notice>: 2017-05-24 15:54:52 +0300 apsd[90]: <PCDispatchTimer: 0x156ad240> performing call back" ,
65
69
"May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG" ,
@@ -86,20 +90,21 @@ describe("iOSLogFilter", () => {
86
90
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION" ,
87
91
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:" ,
88
92
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3478:36: resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:416:40" ,
93
+ "resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:401:31" ,
94
+ "file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:449:31" ,
95
+ "invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:223:42" ,
96
+ "onInvokeTask@file:///app/tns_modules/@angular/core/bundles/core.umd.js:4382:51" ,
97
+ "invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:222:54" ,
98
+ "runTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:123:57" ,
99
+ "drainMicroTaskQueue@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:355:42" ,
100
+ "promiseReactionJob@[native code]" ,
101
+ "UIApplicationMain@[native code]" ,
102
+ "start@file:///app/tns_modules/tns-core-modules/application/application.js:251:26" ,
103
+ "bootstrapApp@file:///app/tns_module" ,
89
104
null ,
90
- null ,
91
- null ,
92
- null ,
93
- null ,
94
- null ,
95
- null ,
96
- null ,
97
- null ,
98
- null ,
99
- null ,
100
- "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
101
105
""
102
106
] ,
107
+ simProjectName : "TestApp" ,
103
108
simulator : [
104
109
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
105
110
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
@@ -113,6 +118,7 @@ describe("iOSLogFilter", () => {
113
118
} ,
114
119
{
115
120
version : 11 ,
121
+ projectName : "NativeScript250" ,
116
122
originalDataArr : [
117
123
"May 24 15:54:52 Dragons-iPhone apsd(PersistentConnection)[90] <Notice>: 2017-05-24 15:54:52 +0300 apsd[90]: <PCDispatchTimer: 0x156ad240> performing call back" ,
118
124
"May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG" ,
@@ -139,20 +145,21 @@ describe("iOSLogFilter", () => {
139
145
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION" ,
140
146
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:" ,
141
147
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3478:36: resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:416:40" ,
148
+ "resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:401:31" ,
149
+ "file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:449:31" ,
150
+ "invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:223:42" ,
151
+ "onInvokeTask@file:///app/tns_modules/@angular/core/bundles/core.umd.js:4382:51" ,
152
+ "invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:222:54" ,
153
+ "runTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:123:57" ,
154
+ "drainMicroTaskQueue@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:355:42" ,
155
+ "promiseReactionJob@[native code]" ,
156
+ "UIApplicationMain@[native code]" ,
157
+ "start@file:///app/tns_modules/tns-core-modules/application/application.js:251:26" ,
158
+ "bootstrapApp@file:///app/tns_module" ,
142
159
null ,
143
- null ,
144
- null ,
145
- null ,
146
- null ,
147
- null ,
148
- null ,
149
- null ,
150
- null ,
151
- null ,
152
- null ,
153
- "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" ,
154
160
""
155
161
] ,
162
+ simProjectName : "cliapp" ,
156
163
simulator : [
157
164
"2017-10-09 13:34:38.527844+0300 localhost cliapp[52946]: (NativeScript) CONSOLE LOG file:///app/main-view-model.js:18:20: Test Console" ,
158
165
"2017-10-09 13:34:38.527844+0300 localhost cliapp[52946]: (NativeScript) CONSOLE DEBUG file:///app/main-view-model.js:18:20: Test Console" ,
@@ -168,45 +175,55 @@ describe("iOSLogFilter", () => {
168
175
const infoLogLevel = "INFO" ;
169
176
const fullLogLevel = "FULL" ;
170
177
171
- beforeEach ( ( ) => {
172
- testInjector = createTestInjector ( ) ;
173
- logFilter = testInjector . resolve ( IOSLogFilter ) ;
174
- } ) ;
178
+ // beforeEach(() => {
179
+ // // testInjector = createTestInjector();
180
+ // // logFilter = testInjector.resolve(IOSLogFilter);
181
+ // });
175
182
176
- describe ( "filterData" , ( ) => {
183
+ describe . only ( "filterData" , ( ) => {
177
184
testData . forEach ( data => {
178
185
it ( `returns correct data when logLevel is ${ fullLogLevel } on iOS ${ data . version } and all data is passed at once` , ( ) => {
186
+ testInjector = createTestInjector ( data . projectName ) ;
187
+ logFilter = testInjector . resolve ( IOSLogFilter ) ;
179
188
const actualData = logFilter . filterData ( data . originalDataArr . join ( "\n" ) , fullLogLevel , null ) ;
180
189
const actualArr = actualData . split ( "\n" ) . map ( line => line . trim ( ) ) ;
181
- const expectedArr = data . originalDataArr . map ( line => line . trim ( ) ) ;
190
+ const expectedArr = data . originalDataArr . map ( line => line . trim ( ) ) . filter ( item => item !== null ) ;
182
191
assert . deepEqual ( actualArr , expectedArr ) ;
183
192
} ) ;
184
193
185
194
it ( `returns correct data when logLevel is ${ fullLogLevel } on iOS ${ data . version } and data is passed one line at a time` , ( ) => {
186
195
data . originalDataArr . forEach ( line => {
196
+ testInjector = createTestInjector ( data . projectName ) ;
197
+ logFilter = testInjector . resolve ( IOSLogFilter ) ;
187
198
const actualData = logFilter . filterData ( line , fullLogLevel , null ) ;
188
199
assert . deepEqual ( actualData . trim ( ) , line . trim ( ) ) ;
189
200
} ) ;
190
201
} ) ;
191
202
192
203
it ( `parses data incorrectly when logLevel is ${ infoLogLevel } on iOS ${ data . version } and all data is passed at once with pid(simulator)` , ( ) => {
204
+ testInjector = createTestInjector ( data . simProjectName ) ;
205
+ logFilter = testInjector . resolve ( IOSLogFilter ) ;
193
206
const actualData = logFilter . filterData ( data . simulator . join ( "\n" ) , infoLogLevel , pid ) ;
194
207
const actualArr = actualData . split ( "\n" ) . map ( line => line . trim ( ) ) ;
195
- assert . deepEqual ( actualArr , data . simulatorExpectedArr ) ;
208
+ assert . deepEqual ( actualArr , data . simulatorExpectedArr . filter ( item => item !== null ) ) ;
196
209
} ) ;
197
210
198
211
it ( `parses data incorrectly when logLevel is ${ infoLogLevel } on iOS ${ data . version } and all data is passed at once and pid is available` , ( ) => {
212
+ testInjector = createTestInjector ( data . projectName ) ;
213
+ logFilter = testInjector . resolve ( IOSLogFilter ) ;
199
214
const actualData = logFilter . filterData ( data . originalDataArr . join ( "\n" ) , infoLogLevel , null ) ;
200
215
const actualArr = actualData . split ( "\n" ) . map ( line => line . trim ( ) ) ;
201
- const expectedArr = [ "CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG" , "" ] ;
216
+ const expectedArr = data . infoExpectedArr . filter ( item => item !== null ) ;
202
217
assert . deepEqual ( actualArr , expectedArr ) ;
203
218
} ) ;
204
219
205
220
it ( `returns correct data when logLevel is ${ infoLogLevel } on iOS ${ data . version } and data is passed one line at a time` , ( ) => {
221
+ testInjector = createTestInjector ( data . projectName ) ;
222
+ logFilter = testInjector . resolve ( IOSLogFilter ) ;
206
223
data . originalDataArr . forEach ( ( line , index ) => {
207
224
const actualData = logFilter . filterData ( line , infoLogLevel , null ) ;
208
225
const expectedData = data . infoExpectedArr [ index ] ;
209
- assert . deepEqual ( actualData && actualData . trim ( ) , expectedData && expectedData ) ;
226
+ assert . equal ( actualData && actualData . trim ( ) , expectedData && expectedData ) ;
210
227
} ) ;
211
228
} ) ;
212
229
} ) ;
0 commit comments