Skip to content

Commit

Permalink
Merge pull request #77 from tfoxy/master
Browse files Browse the repository at this point in the history
Set props and methods as enumerable and configurable
  • Loading branch information
acvetkov committed May 11, 2018
2 parents deef1db + 5729708 commit 2816714
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/api/index.js
Expand Up @@ -81,7 +81,9 @@ export default class Api {
Object.defineProperty(result, func.name, {
get: function () {
return stubs.get(func.name, namespace);
}
},
enumerable: true,
configurable: true
});
return obj;
}, obj);
Expand All @@ -99,7 +101,9 @@ export default class Api {
Object.defineProperty(result, event.name, {
get: function () {
return ev.get(event.name, namespace);
}
},
enumerable: true,
configurable: true
});
return obj;
}, obj);
Expand Down Expand Up @@ -155,7 +159,9 @@ export default class Api {
return Object.defineProperty(obj, prop, {
get() {
return instance.get();
}
},
enumerable: true,
configurable: true
});
}
const property = this.props.get(prop, `${namespace}`, value);
Expand All @@ -165,7 +171,9 @@ export default class Api {
},
set(newValue) {
property.current = newValue;
}
},
enumerable: true,
configurable: true
});
}
}
42 changes: 42 additions & 0 deletions test/specs/chrome.test.js
Expand Up @@ -129,3 +129,45 @@ describe('chrome/flush', function () {
assert.isNull(chrome.runtime.id);
});
});

describe.only('chrome api', function () {

describe('functions', function () {

it('should be enumerable', function () {
const descriptor = Object.getOwnPropertyDescriptor(chrome.tabs, 'create');
assert(descriptor.enumerable);
});

it('should be configurable', function () {
const descriptor = Object.getOwnPropertyDescriptor(chrome.tabs, 'create');
assert(descriptor.configurable);
});
});

describe('props', function () {

it('should be enumerable', function () {
const descriptor = Object.getOwnPropertyDescriptor(chrome.runtime, 'id');
assert(descriptor.enumerable);
});

it('should be configurable', function () {
const descriptor = Object.getOwnPropertyDescriptor(chrome.runtime, 'id');
assert(descriptor.configurable);
});
});

describe('events', function () {

it('should be enumerable', function () {
const descriptor = Object.getOwnPropertyDescriptor(chrome.tabs, 'onCreated');
assert(descriptor.enumerable);
});

it('should be configurable', function () {
const descriptor = Object.getOwnPropertyDescriptor(chrome.tabs, 'onCreated');
assert(descriptor.configurable);
});
});
});

0 comments on commit 2816714

Please sign in to comment.