blob: d89e7dcbaf03d1b84bbbf7196ffa326d18ab7a9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* global describe, it */
var requireMainFilename = require('./')
require('tap').mochaGlobals()
require('chai').should()
describe('require-main-filename', function () {
it('returns require.main.filename in normal circumstances', function () {
requireMainFilename().should.match(/test\.js/)
})
it('should use children[0].filename when running on iisnode', function () {
var main = {
filename: 'D:\\Program Files (x86)\\iisnode\\interceptor.js',
children: [ {filename: 'D:\\home\\site\\wwwroot\\server.js'} ]
}
requireMainFilename({
main: main
}).should.match(/server\.js/)
})
it('should not use children[0] if no children exist', function () {
var main = {
filename: 'D:\\Program Files (x86)\\iisnode\\interceptor.js',
children: []
}
requireMainFilename({
main: main
}).should.match(/interceptor\.js/)
})
it('should default to process.cwd() if require.main is undefined', function () {
requireMainFilename({}).should.match(/require-main-filename/)
})
})
|