11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// A package.json with an empty "main" property should use index.js if present. 51cb0ef41Sopenharmony_ci// require.resolve() should resolve to index.js for the same reason. 61cb0ef41Sopenharmony_ci// 71cb0ef41Sopenharmony_ci// In fact, any "main" property that doesn't resolve to a file should result 81cb0ef41Sopenharmony_ci// in index.js being used, but that's already checked for by other tests. 91cb0ef41Sopenharmony_ci// This test only concerns itself with the empty string. 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst assert = require('assert'); 121cb0ef41Sopenharmony_ciconst path = require('path'); 131cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst where = fixtures.path('require-empty-main'); 161cb0ef41Sopenharmony_ciconst expected = path.join(where, 'index.js'); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_citest(); 191cb0ef41Sopenharmony_cisetImmediate(test); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cifunction test() { 221cb0ef41Sopenharmony_ci assert.strictEqual(require.resolve(where), expected); 231cb0ef41Sopenharmony_ci assert.strictEqual(require(where), 42); 241cb0ef41Sopenharmony_ci assert.strictEqual(require.resolve(where), expected); 251cb0ef41Sopenharmony_ci} 26