mechanicsSpec.js 714 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. var expect = require('chai').expect;
  3. var hasProperty = require('./has-property');
  4. describe('Object.defineProperty mechanics', function() {
  5. it('should have null property', function() {
  6. // given
  7. var a = {};
  8. // when
  9. Object.defineProperty(a, 'foo', {
  10. value: undefined
  11. });
  12. // then
  13. expect(a.value).not.to.exist;
  14. expect(hasProperty(a, 'foo')).to.equal(true);
  15. });
  16. it('should not have property after deletion', function() {
  17. // given
  18. var a = {};
  19. Object.defineProperty(a, 'foo', {
  20. value: undefined,
  21. configurable: true
  22. });
  23. // when
  24. delete a.foo;
  25. // then
  26. expect(hasProperty(a, 'foo')).to.equal(false);
  27. });
  28. });