source: imaps-frontend/node_modules/has-property-descriptors/test/index.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.4 KB
Line 
1'use strict';
2
3var test = require('tape');
4
5var hasPropertyDescriptors = require('../');
6
7var sentinel = {};
8
9test('hasPropertyDescriptors', function (t) {
10 t.equal(typeof hasPropertyDescriptors, 'function', 'is a function');
11 t.equal(typeof hasPropertyDescriptors.hasArrayLengthDefineBug, 'function', '`hasArrayLengthDefineBug` property is a function');
12
13 var yes = hasPropertyDescriptors();
14 t.test('property descriptors', { skip: !yes }, function (st) {
15 var o = { a: sentinel };
16
17 st.deepEqual(
18 Object.getOwnPropertyDescriptor(o, 'a'),
19 {
20 configurable: true,
21 enumerable: true,
22 value: sentinel,
23 writable: true
24 },
25 'has expected property descriptor'
26 );
27
28 Object.defineProperty(o, 'a', { enumerable: false, writable: false });
29
30 st.deepEqual(
31 Object.getOwnPropertyDescriptor(o, 'a'),
32 {
33 configurable: true,
34 enumerable: false,
35 value: sentinel,
36 writable: false
37 },
38 'has expected property descriptor after [[Define]]'
39 );
40
41 st.end();
42 });
43
44 var arrayBug = hasPropertyDescriptors.hasArrayLengthDefineBug();
45 t.test('defining array lengths', { skip: !yes || arrayBug }, function (st) {
46 var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
47 st.equal(arr.length, 3, 'array starts with length 3');
48
49 Object.defineProperty(arr, 'length', { value: 5 });
50
51 st.equal(arr.length, 5, 'array ends with length 5');
52
53 st.end();
54 });
55
56 t.end();
57});
Note: See TracBrowser for help on using the repository browser.