'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
 
var test = require('tape');
var isDescriptor = require('../');
var noop = function () {};
 
test('isDescriptor', function (t) {
    t.test('value type', function (st) {
        st.notOk(isDescriptor('a'), 'string is not a descriptor');
        st.notOk(isDescriptor(null), 'null is not a descriptor');
 
        st.end();
    });
 
    t.test('should not be false when the object has unknown properties:', function (st) {
        st.ok(isDescriptor({ value: 'foo', bar: 'baz' }));
        st.ok(isDescriptor({ value: 'foo', bar: 'baz' }));
 
        st.end();
    });
 
    t.test('should be false when the object has accessor properties', function (st) {
        st.notOk(isDescriptor({ value: 'foo', get: noop }));
        st.notOk(isDescriptor({ set: noop, value: noop }));
 
        st.end();
    });
 
    t.test('should be true when the object has valid data-descriptor properties', function (st) {
        st.ok(isDescriptor({ value: 'foo' }));
        st.ok(isDescriptor({ value: noop }));
 
        st.end();
    });
 
    t.test('should be false when valid properties are invalid types', function (st) {
        st.notOk(isDescriptor({ value: 'foo', enumerable: 'foo' }));
        st.notOk(isDescriptor({ value: 'foo', configurable: 'foo' }));
        st.notOk(isDescriptor({ value: 'foo', writable: 'foo' }));
 
        st.end();
    });
 
    t.test('should be true when a value is a valid data descriptor', function (st) {
        st.ok(isDescriptor({ value: 'foo' }));
        st.ok(isDescriptor({ writable: true }));
 
        st.end();
    });
 
    t.test('should be false when the value is not a valid descriptor', function (st) {
        st.notOk(isDescriptor('foo'));
        st.notOk(isDescriptor({}));
        st.notOk(isDescriptor({ configurable: true }));
        st.notOk(isDescriptor({ enumerable: true }));
        st.notOk(isDescriptor({
            get: undefined,
            set: undefined,
            enumerable: true,
            configurable: true,
        }));
 
        st.end();
    });
 
    t.end();
});