1'use strict';
2require('../common');
3
4// A package.json with an empty "main" property should use index.js if present.
5// require.resolve() should resolve to index.js for the same reason.
6//
7// In fact, any "main" property that doesn't resolve to a file should result
8// in index.js being used, but that's already checked for by other tests.
9// This test only concerns itself with the empty string.
10
11const assert = require('assert');
12const path = require('path');
13const fixtures = require('../common/fixtures');
14
15const where = fixtures.path('require-empty-main');
16const expected = path.join(where, 'index.js');
17
18test();
19setImmediate(test);
20
21function test() {
22  assert.strictEqual(require.resolve(where), expected);
23  assert.strictEqual(require(where), 42);
24  assert.strictEqual(require.resolve(where), expected);
25}
26