UNPKG

@t7/utils

Version:

Utility methods for T7 components.

48 lines (37 loc) 1.52 kB
"use strict"; var _ = require("./"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } // Describe test. describe('bind', function () { // ============ // Dummy class. // ============ var F = /*#__PURE__*/ function () { function F() { _classCallCheck(this, F); } _createClass(F, [{ key: "example", value: function example() {} }, { key: "setState", value: function setState() {} }]); return F; }(); // Spy. F.prototype.example.bind = jest.fn(); F.prototype.setState.bind = jest.fn(); // ====================== // Test for "bind" event. // ====================== it('handles "bind" event', function () { // Get instance. var f = new F(); // Fire event. (0, _.bind)(f); expect(F.prototype.example.bind).toBeCalled(); expect(F.prototype.setState.bind).toBeCalled(); }); });