Projekt

Obecné

Profil

Stáhnout (1.03 KB) Statistiky
| Větev: | Revize:
1
/* global describe, it */
2

    
3
var requireMainFilename = require('./')
4

    
5
require('tap').mochaGlobals()
6
require('chai').should()
7

    
8
describe('require-main-filename', function () {
9
  it('returns require.main.filename in normal circumstances', function () {
10
    requireMainFilename().should.match(/test\.js/)
11
  })
12

    
13
  it('should use children[0].filename when running on iisnode', function () {
14
    var main = {
15
      filename: 'D:\\Program Files (x86)\\iisnode\\interceptor.js',
16
      children: [ {filename: 'D:\\home\\site\\wwwroot\\server.js'} ]
17
    }
18
    requireMainFilename({
19
      main: main
20
    }).should.match(/server\.js/)
21
  })
22

    
23
  it('should not use children[0] if no children exist', function () {
24
    var main = {
25
      filename: 'D:\\Program Files (x86)\\iisnode\\interceptor.js',
26
      children: []
27
    }
28
    requireMainFilename({
29
      main: main
30
    }).should.match(/interceptor\.js/)
31
  })
32

    
33
  it('should default to process.cwd() if require.main is undefined', function () {
34
    requireMainFilename({}).should.match(/require-main-filename/)
35
  })
36
})
(6-6/6)