diff options
Diffstat (limited to 'js/vendor/es6-shim/test-sham')
-rw-r--r-- | js/vendor/es6-shim/test-sham/function.js | 54 | ||||
-rw-r--r-- | js/vendor/es6-shim/test-sham/index.html | 1 |
2 files changed, 55 insertions, 0 deletions
diff --git a/js/vendor/es6-shim/test-sham/function.js b/js/vendor/es6-shim/test-sham/function.js new file mode 100644 index 000000000..43d8459a2 --- /dev/null +++ b/js/vendor/es6-shim/test-sham/function.js @@ -0,0 +1,54 @@ +/* global describe, it, xit, expect, require, beforeEach, afterEach */ + +describe('Function', function () { + describe('#name', function () { + it('returns the name for named functions', function () { + var foo = function bar() {}; + expect(foo.name).to.equal('bar'); + + // pre-ES6, this property is nonconfigurable. + var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(foo, 'name').configurable : false; + + expect(foo).to.have.ownPropertyDescriptor('name', { + configurable: !!configurable, + enumerable: false, + writable: false, + value: 'bar' + }); + }); + + it('returns empty string for anonymous functions', function () { + var anon = function () {}; + expect(anon.name).to.equal(''); + + // pre-ES6, this property is nonconfigurable. + var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(anon, 'name').configurable : false; + + expect(anon).to.have.ownPropertyDescriptor('name', { + configurable: !!configurable, + enumerable: false, + writable: false, + value: '' + }); + }); + + it('returns "anomymous" for Function functions', function () { + /* eslint no-new-func: 1 */ + /* jshint evil: true */ + var func = Function(''); + /* jshint evil: false */ + expect(typeof func.name).to.equal('string'); + expect(func.name === 'anonymous' || func.name === '').to.equal(true); + + // pre-ES6, this property is nonconfigurable. + var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(func, 'name').configurable : false; + + expect(func).to.have.ownPropertyDescriptor('name', { + configurable: !!configurable, + enumerable: false, + writable: false, + value: func.name + }); + }); + }); +}); diff --git a/js/vendor/es6-shim/test-sham/index.html b/js/vendor/es6-shim/test-sham/index.html index e83204d0f..2919ad4a0 100644 --- a/js/vendor/es6-shim/test-sham/index.html +++ b/js/vendor/es6-shim/test-sham/index.html @@ -13,6 +13,7 @@ <script src="../es6-sham.js"></script> <script src="../test/browser-setup.js"></script> <script src="set-prototype-of.js"></script> + <script src="function.js"></script> <script src="../test/browser-onload.js"></script> </head> <body> |