has.js 514 B

123456789101112131415
  1. 'use strict';
  2. var inspect = require('../');
  3. var test = require('tape');
  4. var mockProperty = require('mock-property');
  5. test('when Object#hasOwnProperty is deleted', function (t) {
  6. t.plan(1);
  7. var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
  8. t.teardown(mockProperty(Array.prototype, 1, { value: 2 })); // this is needed to account for "in" vs "hasOwnProperty"
  9. t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
  10. t.equal(inspect(arr), '[ 1, , 3 ]');
  11. });