UNPKG

playable

Version:

Video player based on HTML5Video

101 lines 4.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var chai_1 = require("chai"); var player_api_decorator_1 = (0, tslib_1.__importStar)(require("./player-api-decorator")); describe('Decorator playerAPI', function () { it('should add method to private property in prototype', function () { var A = /** @class */ (function () { function A() { } A.prototype.a = function () { }; A.prototype.b = function () { }; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], A.prototype, "a", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], A.prototype, "b", null); return A; }()); (0, chai_1.expect)(A.prototype[player_api_decorator_1.PLAYER_API_PROPERTY]).to.deep.equal({ a: Reflect.getOwnPropertyDescriptor(A.prototype, 'a'), b: Reflect.getOwnPropertyDescriptor(A.prototype, 'b'), }); }); it('should add method to private property in prototype with custom key', function () { var A = /** @class */ (function () { function A() { } A.prototype.a = function () { }; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)('b') ], A.prototype, "a", null); return A; }()); (0, chai_1.expect)(A.prototype[player_api_decorator_1.PLAYER_API_PROPERTY]).to.deep.equal({ b: Reflect.getOwnPropertyDescriptor(A.prototype, 'a'), }); }); it('should add descriptor if setter or getter', function () { var A = /** @class */ (function () { function A() { } Object.defineProperty(A.prototype, "a", { get: function () { return; }, enumerable: false, configurable: true }); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)('b') ], A.prototype, "a", null); return A; }()); (0, chai_1.expect)(A.prototype[player_api_decorator_1.PLAYER_API_PROPERTY]).to.deep.equal({ b: Reflect.getOwnPropertyDescriptor(A.prototype, 'a'), }); }); it('should add descriptor if setter and getter', function () { var A = /** @class */ (function () { function A() { } Object.defineProperty(A.prototype, "a", { get: function () { return; }, set: function (_) { }, enumerable: false, configurable: true }); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], A.prototype, "a", null); return A; }()); (0, chai_1.expect)(A.prototype[player_api_decorator_1.PLAYER_API_PROPERTY]).to.deep.equal({ a: Reflect.getOwnPropertyDescriptor(A.prototype, 'a'), }); }); it('should throw error if same keys for public API', function () { var getWrongDecoratedClassB = function () { var B = /** @class */ (function () { function B() { } B.prototype.a = function () { }; B.prototype.b = function () { }; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)('b') ], B.prototype, "a", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], B.prototype, "b", null); return B; }()); return B; }; (0, chai_1.expect)(getWrongDecoratedClassB).to.throw('Method "b" for public API in B is already defined'); }); }); //# sourceMappingURL=player-api-decorator.spec.js.map