main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $defineProperty = require('../');
|
---|
4 |
|
---|
5 | var test = require('tape');
|
---|
6 | var gOPD = require('gopd');
|
---|
7 |
|
---|
8 | test('defineProperty: supported', { skip: !$defineProperty }, function (t) {
|
---|
9 | t.plan(4);
|
---|
10 |
|
---|
11 | t.equal(typeof $defineProperty, 'function', 'defineProperty is supported');
|
---|
12 | if ($defineProperty && gOPD) { // this `if` check is just to shut TS up
|
---|
13 | var o = { a: 1 };
|
---|
14 |
|
---|
15 | $defineProperty(o, 'b', { enumerable: true, value: 2 });
|
---|
16 | t.deepEqual(
|
---|
17 | gOPD(o, 'b'),
|
---|
18 | {
|
---|
19 | configurable: false,
|
---|
20 | enumerable: true,
|
---|
21 | value: 2,
|
---|
22 | writable: false
|
---|
23 | },
|
---|
24 | 'property descriptor is as expected'
|
---|
25 | );
|
---|
26 |
|
---|
27 | $defineProperty(o, 'c', { enumerable: false, value: 3, writable: true });
|
---|
28 | t.deepEqual(
|
---|
29 | gOPD(o, 'c'),
|
---|
30 | {
|
---|
31 | configurable: false,
|
---|
32 | enumerable: false,
|
---|
33 | value: 3,
|
---|
34 | writable: true
|
---|
35 | },
|
---|
36 | 'property descriptor is as expected'
|
---|
37 | );
|
---|
38 | }
|
---|
39 |
|
---|
40 | t.equal($defineProperty, Object.defineProperty, 'defineProperty is Object.defineProperty');
|
---|
41 |
|
---|
42 | t.end();
|
---|
43 | });
|
---|
44 |
|
---|
45 | test('defineProperty: not supported', { skip: !!$defineProperty }, function (t) {
|
---|
46 | t.notOk($defineProperty, 'defineProperty is not supported');
|
---|
47 |
|
---|
48 | t.match(
|
---|
49 | typeof $defineProperty,
|
---|
50 | /^(?:undefined|boolean)$/,
|
---|
51 | '`typeof defineProperty` is `undefined` or `boolean`'
|
---|
52 | );
|
---|
53 |
|
---|
54 | t.end();
|
---|
55 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.