Commit 45b38912 authored by Vadym Gidulian's avatar Vadym Gidulian

Closed #1 (Fix property descriptors)

parent 1900d971
......@@ -17,11 +17,14 @@ function PromisedValue(initialValue) {
Object.defineProperties(this, {
isReady: {
enumerable: true,
get() {
return initialized;
}
},
value: {
configurable: true,
enumerable: true,
get() {
return value;
},
......@@ -37,6 +40,7 @@ function PromisedValue(initialValue) {
}
},
willBeReady: {
enumerable: true,
get() {
return willBeReady;
}
......
......@@ -32,3 +32,25 @@ test('Use new only', t => {
t.pass();
}
});
test('Property descriptors', t => {
const v = new PV(42);
t.true(Object.keys(v).toString() === ['isReady', 'value', 'willBeReady'].toString());
Object.defineProperty(v, 'value', {
value: 42,
writable: false
});
t.is(v.value, 42);
try {
v.value = 43;
t.fail('An exception should be thrown');
} catch (e) {
t.pass();
}
delete v.value;
t.false(v.hasOwnProperty('value'));
t.true(Object.keys(v).toString() === ['isReady', 'willBeReady'].toString());
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment