source: imaps-frontend/node_modules/es-define-property/test/index.js@ 79a0317

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2
3var $defineProperty = require('../');
4
5var test = require('tape');
6var gOPD = require('gopd');
7
8test('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 /** @type {{ a: number, b?: number, c?: number }} */
14 var o = { a: 1 };
15
16 $defineProperty(o, 'b', { enumerable: true, value: 2 });
17 t.deepEqual(
18 gOPD(o, 'b'),
19 {
20 configurable: false,
21 enumerable: true,
22 value: 2,
23 writable: false
24 },
25 'property descriptor is as expected'
26 );
27
28 $defineProperty(o, 'c', { enumerable: false, value: 3, writable: true });
29 t.deepEqual(
30 gOPD(o, 'c'),
31 {
32 configurable: false,
33 enumerable: false,
34 value: 3,
35 writable: true
36 },
37 'property descriptor is as expected'
38 );
39 }
40
41 t.equal($defineProperty, Object.defineProperty, 'defineProperty is Object.defineProperty');
42
43 t.end();
44});
45
46test('defineProperty: not supported', { skip: !!$defineProperty }, function (t) {
47 t.notOk($defineProperty, 'defineProperty is not supported');
48
49 t.match(
50 typeof $defineProperty,
51 /^(?:undefined|boolean)$/,
52 '`typeof defineProperty` is `undefined` or `boolean`'
53 );
54
55 t.end();
56});
Note: See TracBrowser for help on using the repository browser.