@@ -59,20 +59,20 @@ describe('path-line', function () {
59
59
} )
60
60
} )
61
61
62
- describe ( 'getNonDDFrames ' , ( ) => {
62
+ describe ( 'getNonDDCallSiteFrames ' , ( ) => {
63
63
describe ( 'does not fail' , ( ) => {
64
64
it ( 'with null parameter' , ( ) => {
65
- const result = pathLine . getNonDDFrames ( null )
65
+ const result = pathLine . getNonDDCallSiteFrames ( null )
66
66
expect ( result ) . to . be . an ( 'array' ) . that . is . empty
67
67
} )
68
68
69
69
it ( 'with empty list parameter' , ( ) => {
70
- const result = pathLine . getNonDDFrames ( [ ] )
70
+ const result = pathLine . getNonDDCallSiteFrames ( [ ] )
71
71
expect ( result ) . to . be . an ( 'array' ) . that . is . empty
72
72
} )
73
73
74
74
it ( 'without parameter' , ( ) => {
75
- const result = pathLine . getNonDDFrames ( )
75
+ const result = pathLine . getNonDDCallSiteFrames ( )
76
76
expect ( result ) . to . be . an ( 'array' ) . that . is . empty
77
77
} )
78
78
} )
@@ -108,7 +108,7 @@ describe('path-line', function () {
108
108
callsites . push ( new CallSiteMock ( firstFileOutOfDD , 13 , 42 ) )
109
109
callsites . push ( new CallSiteMock ( secondFileOutOfDD , 20 , 15 ) )
110
110
111
- const results = pathLine . getNonDDFrames ( callsites )
111
+ const results = pathLine . getNonDDCallSiteFrames ( callsites )
112
112
113
113
expect ( results ) . to . have . lengthOf ( 2 )
114
114
@@ -127,7 +127,7 @@ describe('path-line', function () {
127
127
callsites . push ( new CallSiteMock ( path . join ( DD_BASE_PATH , 'other' , 'file' , 'in' , 'dd.js' ) , 89 ) )
128
128
callsites . push ( new CallSiteMock ( path . join ( DD_BASE_PATH , 'another' , 'file' , 'in' , 'dd.js' ) , 5 ) )
129
129
130
- const results = pathLine . getNonDDFrames ( callsites )
130
+ const results = pathLine . getNonDDCallSiteFrames ( callsites )
131
131
expect ( results ) . to . be . an ( 'array' ) . that . is . empty
132
132
} )
133
133
@@ -142,7 +142,7 @@ describe('path-line', function () {
142
142
callsites . push ( new CallSiteMock ( dcPath , 25 ) )
143
143
callsites . push ( new CallSiteMock ( firstFileOutOfDD , 13 , 42 ) )
144
144
145
- const results = pathLine . getNonDDFrames ( callsites )
145
+ const results = pathLine . getNonDDCallSiteFrames ( callsites )
146
146
expect ( results ) . to . have . lengthOf ( 1 )
147
147
148
148
expect ( results [ 0 ] . path ) . to . be . equals ( expectedFilePath )
@@ -184,7 +184,7 @@ describe('path-line', function () {
184
184
callsites . push ( new CallSiteMock ( firstFileOutOfDD , 13 , 42 ) )
185
185
callsites . push ( new CallSiteMock ( secondFileOutOfDD , 20 , 15 ) )
186
186
187
- const results = pathLine . getNonDDFrames ( callsites )
187
+ const results = pathLine . getNonDDCallSiteFrames ( callsites )
188
188
expect ( results ) . to . have . lengthOf ( 2 )
189
189
190
190
expect ( results [ 0 ] . path ) . to . be . equals ( expectedFilePaths [ 0 ] )
@@ -199,36 +199,37 @@ describe('path-line', function () {
199
199
} )
200
200
201
201
describe ( 'getNodeModulesPaths' , ( ) => {
202
- // function getCallSiteInfo () {
203
- // const previousPrepareStackTrace = Error.prepareStackTrace
204
- // const previousStackTraceLimit = Error.stackTraceLimit
205
- // let callsiteList
206
- // Error.stackTraceLimit = 100
207
- // Error.prepareStackTrace = function (_, callsites) {
208
- // callsiteList = callsites
209
- // }
210
- // const e = new Error()
211
- // e.stack
212
- // Error.prepareStackTrace = previousPrepareStackTrace
213
- // Error.stackTraceLimit = previousStackTraceLimit
214
-
215
- // return callsiteList
216
- // }
217
- // TODO: propose another test similar to this
218
- // it('should handle windows paths correctly', () => {
219
- // const basePath = pathLine.ddBasePath
220
- // pathLine.ddBasePath = path.join('test', 'base', 'path')
221
- // const { getFramesForMetaStruct } = require('../../../src/appsec/stack_trace')
222
-
223
- // const list = getFramesForMetaStruct(32, getCallSiteInfo)
224
- // const firstNonDDPath = pathLine.getNonDDFrames(list)[0]
225
-
226
- // const nodeModulesPaths = pathLine.getNodeModulesPaths(__filename)
227
-
228
- // expect(nodeModulesPaths[0]).to.eq(path.join('node_modules', process.cwd(), firstNonDDPath.path))
229
-
230
- // pathLine.ddBasePath = basePath
231
- // })
202
+ function getCallSiteInfo ( ) {
203
+ const previousPrepareStackTrace = Error . prepareStackTrace
204
+ const previousStackTraceLimit = Error . stackTraceLimit
205
+ let callsiteList
206
+ Error . stackTraceLimit = 100
207
+ Error . prepareStackTrace = function ( _ , callsites ) {
208
+ callsiteList = callsites
209
+ }
210
+ const e = new Error ( )
211
+ e . stack
212
+ Error . prepareStackTrace = previousPrepareStackTrace
213
+ Error . stackTraceLimit = previousStackTraceLimit
214
+
215
+ return callsiteList
216
+ }
217
+
218
+ it ( 'should handle windows paths correctly' , ( ) => {
219
+ const basePath = pathLine . ddBasePath
220
+ pathLine . ddBasePath = path . join ( 'test' , 'base' , 'path' )
221
+ const { getCallsiteFrames } = require ( '../../../src/appsec/stack_trace' )
222
+
223
+ const list = getCallsiteFrames ( 32 , getCallSiteInfo )
224
+ const firstNonDDPath = pathLine . getNonDDCallSiteFrames ( list ) [ 0 ]
225
+
226
+ const expectedPath = path . join ( 'node_modules' , firstNonDDPath . path )
227
+ const nodeModulesPaths = pathLine . getNodeModulesPaths ( firstNonDDPath . path )
228
+
229
+ expect ( nodeModulesPaths [ 0 ] ) . to . equal ( expectedPath )
230
+
231
+ pathLine . ddBasePath = basePath
232
+ } )
232
233
233
234
it ( 'should convert / to \\ in windows platforms' , ( ) => {
234
235
const dirname = __dirname
0 commit comments