11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
51cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding');
61cb0ef41Sopenharmony_ciconst { filterOwnProperties } = require('internal/util');
71cb0ef41Sopenharmony_ciconst { internalModuleReadJSON } = internalBinding('fs');
81cb0ef41Sopenharmony_ciconst { readFileSync } = require('fs');
91cb0ef41Sopenharmony_ciconst { strictEqual, deepStrictEqual } = require('assert');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci{
121cb0ef41Sopenharmony_ci  strictEqual(internalModuleReadJSON('nosuchfile')[0], undefined);
131cb0ef41Sopenharmony_ci}
141cb0ef41Sopenharmony_ci{
151cb0ef41Sopenharmony_ci  strictEqual(internalModuleReadJSON(fixtures.path('empty.txt'))[0], '');
161cb0ef41Sopenharmony_ci}
171cb0ef41Sopenharmony_ci{
181cb0ef41Sopenharmony_ci  strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt'))[0], '');
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci{
211cb0ef41Sopenharmony_ci  const filename = fixtures.path('require-bin/package.json');
221cb0ef41Sopenharmony_ci  const returnValue = JSON.parse(internalModuleReadJSON(filename)[0]);
231cb0ef41Sopenharmony_ci  const file = JSON.parse(readFileSync(filename, 'utf-8'));
241cb0ef41Sopenharmony_ci  const expectedValue = filterOwnProperties(file, ['name', 'main', 'exports', 'imports', 'type']);
251cb0ef41Sopenharmony_ci  deepStrictEqual({
261cb0ef41Sopenharmony_ci    __proto__: null,
271cb0ef41Sopenharmony_ci    ...returnValue,
281cb0ef41Sopenharmony_ci  }, expectedValue);
291cb0ef41Sopenharmony_ci}
30