@mighty-justice/tester
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -7,2 +7,3 @@ 'use strict'; | ||
var testUtils = require('react-dom/test-utils'); | ||
var React = require('react'); | ||
@@ -883,3 +884,3 @@ var React__default = _interopDefault(React); | ||
if (ms === void 0) { | ||
ms = 0; | ||
ms = 1; | ||
} | ||
@@ -1076,37 +1077,146 @@ | ||
_proto.changeInput = function changeInput(selector, value) { | ||
var component = this.getComponent(selector); | ||
component.simulate('focus'); | ||
component.simulate('change', { | ||
target: { | ||
value: value | ||
} | ||
}); | ||
component.simulate('blur'); | ||
}; | ||
_proto.changeInput = /*#__PURE__*/function () { | ||
var _changeInput = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(selector, value) { | ||
var _this3 = this; | ||
_proto.checkBox = function checkBox(selector, checked) { | ||
if (checked === void 0) { | ||
checked = true; | ||
return runtime_1.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context4.next = 2; | ||
return testUtils.act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() { | ||
var component; | ||
return runtime_1.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
component = _this3.getComponent(selector); | ||
component.simulate('focus'); | ||
component.simulate('change', { | ||
target: { | ||
value: value | ||
} | ||
}); | ||
component.simulate('blur'); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3); | ||
}))); | ||
case 2: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
function changeInput(_x3, _x4) { | ||
return _changeInput.apply(this, arguments); | ||
} | ||
var component = this.getComponent(selector); | ||
component.simulate('change', { | ||
target: { | ||
checked: checked | ||
} | ||
}); | ||
}; | ||
return changeInput; | ||
}(); | ||
_proto.click = function click(selector) { | ||
var component = this.getComponent(selector); | ||
component.simulate('click'); | ||
}; | ||
_proto.checkBox = /*#__PURE__*/function () { | ||
var _checkBox = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(selector, checked) { | ||
var _this4 = this; | ||
return runtime_1.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
if (checked === void 0) { | ||
checked = true; | ||
} | ||
_context6.next = 3; | ||
return testUtils.act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() { | ||
var component; | ||
return runtime_1.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
component = _this4.getComponent(selector); | ||
component.simulate('change', { | ||
target: { | ||
checked: checked | ||
} | ||
}); | ||
case 2: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee5); | ||
}))); | ||
case 3: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee6); | ||
})); | ||
function checkBox(_x5, _x6) { | ||
return _checkBox.apply(this, arguments); | ||
} | ||
return checkBox; | ||
}(); | ||
_proto.click = /*#__PURE__*/function () { | ||
var _click = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(selector) { | ||
var _this5 = this; | ||
return runtime_1.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return testUtils.act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() { | ||
var component; | ||
return runtime_1.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
component = _this5.getComponent(selector); | ||
component.simulate('click'); | ||
case 2: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7); | ||
}))); | ||
case 2: | ||
case "end": | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee8); | ||
})); | ||
function click(_x7) { | ||
return _click.apply(this, arguments); | ||
} | ||
return click; | ||
}(); | ||
_proto.submit = /*#__PURE__*/function () { | ||
var _submit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(selector) { | ||
var component; | ||
return runtime_1.wrap(function _callee3$(_context3) { | ||
var _submit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(selector) { | ||
var _this6 = this; | ||
return runtime_1.wrap(function _callee10$(_context10) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
@@ -1117,16 +1227,31 @@ if (selector === void 0) { | ||
component = this.getComponent(selector); | ||
component.simulate('submit'); | ||
_context3.next = 5; | ||
return this.refresh(); | ||
_context10.next = 3; | ||
return testUtils.act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() { | ||
var component; | ||
return runtime_1.wrap(function _callee9$(_context9) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
component = _this6.getComponent(selector); | ||
component.simulate('submit'); | ||
_context9.next = 4; | ||
return _this6.refresh(); | ||
case 5: | ||
case 4: | ||
case "end": | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee9); | ||
}))); | ||
case 3: | ||
case "end": | ||
return _context3.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
}, _callee10); | ||
})); | ||
function submit(_x3) { | ||
function submit(_x8) { | ||
return _submit.apply(this, arguments); | ||
@@ -1139,8 +1264,8 @@ } | ||
_proto.mount = /*#__PURE__*/function () { | ||
var _mount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(mountOpts) { | ||
var _mount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(mountOpts) { | ||
var validHooks, _iterator, _step, hook, props, initialMount, WrapperTree; | ||
return runtime_1.wrap(function _callee4$(_context4) { | ||
return runtime_1.wrap(function _callee11$(_context11) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
@@ -1156,3 +1281,3 @@ if (mountOpts === void 0) { | ||
if ((_step = _iterator()).done) { | ||
_context4.next = 9; | ||
_context11.next = 9; | ||
break; | ||
@@ -1162,7 +1287,7 @@ } | ||
hook = _step.value; | ||
_context4.next = 7; | ||
_context11.next = 7; | ||
return hook.onBeforeMount(this, mountOpts); | ||
case 7: | ||
_context4.next = 3; | ||
_context11.next = 3; | ||
break; | ||
@@ -1172,15 +1297,15 @@ | ||
if (!this.onBeforeMount) { | ||
_context4.next = 12; | ||
_context11.next = 12; | ||
break; | ||
} | ||
_context4.next = 12; | ||
_context11.next = 12; | ||
return this.onBeforeMount(this); | ||
case 12: | ||
_context4.next = 14; | ||
_context11.next = 14; | ||
return getValue(this, this.props); | ||
case 14: | ||
props = _context4.sent; | ||
props = _context11.sent; | ||
initialMount = this.initialMount || React__default.createElement(this.TestedComponent, Object.assign({}, props)); | ||
@@ -1196,10 +1321,10 @@ WrapperTree = this.getWrappers().reduce(function (Tree, wrapper) { | ||
}, initialMount); | ||
_context4.next = 19; | ||
_context11.next = 19; | ||
return this.config.enzyme.mount(WrapperTree); | ||
case 19: | ||
this.wrapper = _context4.sent; | ||
this.wrapper = _context11.sent; | ||
if (!(mountOpts.async !== false)) { | ||
_context4.next = 28; | ||
_context11.next = 28; | ||
break; | ||
@@ -1209,29 +1334,29 @@ } | ||
if (!(this.instance && typeof this.instance.componentDidMount === 'function')) { | ||
_context4.next = 24; | ||
_context11.next = 24; | ||
break; | ||
} | ||
_context4.next = 24; | ||
_context11.next = 24; | ||
return this.instance.componentDidMount(); | ||
case 24: | ||
_context4.next = 26; | ||
_context11.next = 26; | ||
return flushPromises(); | ||
case 26: | ||
_context4.next = 28; | ||
_context11.next = 28; | ||
return this.refresh(); | ||
case 28: | ||
return _context4.abrupt("return", this); | ||
return _context11.abrupt("return", this); | ||
case 29: | ||
case "end": | ||
return _context4.stop(); | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
}, _callee11, this); | ||
})); | ||
function mount(_x4) { | ||
function mount(_x9) { | ||
return _mount.apply(this, arguments); | ||
@@ -1238,0 +1363,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=(t=e)&&"object"==typeof t&&"default"in t?t.default:t;function r(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function u(t){r(a,o,i,u,c,"next",t)}function c(t){r(a,o,i,u,c,"throw",t)}u(void 0)}))}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function a(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var u,c=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new E(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=x(a,n);if(u){if(u===f)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,i),o}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function h(){}function p(){}function l(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(L([])));m&&m!==e&&n.call(m,o)&&(d=m);var y=l.prototype=h.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var r;this._invoke=function(o,i){function a(){return new e((function(r,a){!function r(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,h=f.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(h).then((function(t){f.value=t,a(f)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function x(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,f;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=y.constructor=l,l.constructor=p,p.displayName=u(l,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new w(c(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),u(y,a,"Generator"),y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=L,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(u={exports:{}}),u.exports);function s(t){var e=t.instance();return e&&(e.wrappedInstance||e)}function f(t){return"function"==typeof t}function h(t,e){return f(e)?e(t):e}function p(t){return l.apply(this,arguments)}function l(){return(l=o(c.mark((function t(e){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=0),t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function d(t){return"string"==typeof t||t instanceof String}function v(){return m.apply(this,arguments)}function m(){return(m=o(c.mark((function t(){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,e){return setImmediate(t)})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var y=function(t){return n.createElement(e.Fragment,Object.assign({},t))},g=function(){function t(e,r){var o=this;void 0===r&&(r={}),this.config=t.Configuration,this.initialMount=r.mount,this.onBeforeMount=r.onBeforeMount,this.opts=r,this.props=r.props||{},this.TestedComponent=e,!this.TestedComponent&&this.initialMount&&(this.TestedComponent=y,this.initialMount=n.createElement(this.TestedComponent,null,this.initialMount)),this.config.getValidHooks("onInit").forEach((function(t){return t.onInit(o)}))}var e,r=t.prototype;return r.getWrappers=function(){var t=this,e=[];return this.config.getValidHooks("component").forEach((function(n){e.push({component:n.component,name:n.name,props:h(t,n.props)})})),e},r.debug=function(){console.log(this.wrapper.debug())},r.html=function(){return this.component.html()},r.text=function(){return this.component.text()},r.find=function(t){return this.wrapper.find(t)},r.update=function(){return this.wrapper.update()},r.sleep=function(){var t=o(c.mark((function t(e){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p(e);case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),r.refresh=function(){var t=o(c.mark((function t(e){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p(e);case 2:this.update();case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getComponent=function(t){return d(t)?this.find(t).first():t},r.changeInput=function(t,e){var n=this.getComponent(t);n.simulate("focus"),n.simulate("change",{target:{value:e}}),n.simulate("blur")},r.checkBox=function(t,e){void 0===e&&(e=!0),this.getComponent(t).simulate("change",{target:{checked:e}})},r.click=function(t){this.getComponent(t).simulate("click")},r.submit=function(){var t=o(c.mark((function t(e){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e="form"),this.getComponent(e).simulate("submit"),t.next=5,this.refresh();case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.mount=function(){var t=o(c.mark((function t(e){var r,o,i,u,s,f,p;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:void 0===e&&(e={}),r=this.config.getValidHooks("onBeforeMount"),o=a(r);case 3:if((i=o()).done){t.next=9;break}return u=i.value,t.next=7,u.onBeforeMount(this,e);case 7:t.next=3;break;case 9:if(!this.onBeforeMount){t.next=12;break}return t.next=12,this.onBeforeMount(this);case 12:return t.next=14,h(this,this.props);case 14:return s=t.sent,f=this.initialMount||n.createElement(this.TestedComponent,Object.assign({},s)),p=this.getWrappers().reduce((function(t,e){var r=!1!==e.renderChildren&&t;return e.props?n.createElement(e.component,Object.assign({},e.props),r):t}),f),t.next=19,this.config.enzyme.mount(p);case 19:if(this.wrapper=t.sent,!1===e.async){t.next=28;break}if(!this.instance||"function"!=typeof this.instance.componentDidMount){t.next=24;break}return t.next=24,this.instance.componentDidMount();case 24:return t.next=26,v();case 26:return t.next=28,this.refresh();case 28:return t.abrupt("return",this);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),(e=[{key:"instance",get:function(){return s(this.component)}},{key:"component",get:function(){return this.wrapper.find(this.TestedComponent)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}(),w=new(function(){function t(t){this.hooks={},this.Tester=t,t.Configuration=this}var e=t.prototype;return e.configure=function(t,e){var n=this;return this.enzyme=t,e.hooks&&e.hooks.forEach((function(t){n.registerHook(t)})),this.Tester},e.registerHook=function(t){if(!t.name)throw new Error("Tester.registerHook() : A hooks must have a name.");if(this.hooks[t.name])throw new Error('Tester.registerHook() : A hook named "'+t.name+'" already exist.');this.hooks[t.name]=t},e.getValidHooks=function(t){var e=[];return Object.values(this.hooks).forEach((function(n){var r=!0;t&&!n[t]&&(r=!1),r&&e.push(n)})),e},t}())(g);exports.Tester=g,exports.TesterConfig=w,exports.flushPromises=v,exports.getInstance=s,exports.getValue=h,exports.isFunction=f,exports.isString=d,exports.sleep=p; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react-dom/test-utils"),r=require("react"),n=(t=r)&&"object"==typeof t&&"default"in t?t.default:t;function o(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function u(t){o(a,n,i,u,c,"next",t)}function c(t){o(a,n,i,u,c,"throw",t)}u(void 0)}))}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return a(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var c,s=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new E(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=x(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function h(){}function p(){}function l(){}var v={};v[o]=function(){return this};var d=Object.getPrototypeOf,m=d&&d(d(L([])));m&&m!==e&&r.call(m,o)&&(v=m);var y=l.prototype=h.prototype=Object.create(v);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,h=f.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(h).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=y.constructor=l,l.constructor=p,p.displayName=u(l,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),u(y,a,"Generator"),y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(c={exports:{}}),c.exports);function f(t){var e=t.instance();return e&&(e.wrappedInstance||e)}function h(t){return"function"==typeof t}function p(t,e){return h(e)?e(t):e}function l(t){return v.apply(this,arguments)}function v(){return(v=i(s.mark((function t(e){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e=1),t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function d(t){return"string"==typeof t||t instanceof String}function m(){return y.apply(this,arguments)}function y(){return(y=i(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,e){return setImmediate(t)})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var g=function(t){return n.createElement(r.Fragment,Object.assign({},t))},w=function(){function t(e,r){var o=this;void 0===r&&(r={}),this.config=t.Configuration,this.initialMount=r.mount,this.onBeforeMount=r.onBeforeMount,this.opts=r,this.props=r.props||{},this.TestedComponent=e,!this.TestedComponent&&this.initialMount&&(this.TestedComponent=g,this.initialMount=n.createElement(this.TestedComponent,null,this.initialMount)),this.config.getValidHooks("onInit").forEach((function(t){return t.onInit(o)}))}var r,o=t.prototype;return o.getWrappers=function(){var t=this,e=[];return this.config.getValidHooks("component").forEach((function(r){e.push({component:r.component,name:r.name,props:p(t,r.props)})})),e},o.debug=function(){console.log(this.wrapper.debug())},o.html=function(){return this.component.html()},o.text=function(){return this.component.text()},o.find=function(t){return this.wrapper.find(t)},o.update=function(){return this.wrapper.update()},o.sleep=function(){var t=i(s.mark((function t(e){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l(e);case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),o.refresh=function(){var t=i(s.mark((function t(e){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l(e);case 2:this.update();case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),o.getComponent=function(t){return d(t)?this.find(t).first():t},o.changeInput=function(){var t=i(s.mark((function t(r,n){var o=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.act(i(s.mark((function t(){var e;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(e=o.getComponent(r)).simulate("focus"),e.simulate("change",{target:{value:n}}),e.simulate("blur");case 4:case"end":return t.stop()}}),t)}))));case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),o.checkBox=function(){var t=i(s.mark((function t(r,n){var o=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=!0),t.next=3,e.act(i(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o.getComponent(r).simulate("change",{target:{checked:n}});case 2:case"end":return t.stop()}}),t)}))));case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),o.click=function(){var t=i(s.mark((function t(r){var n=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.act(i(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n.getComponent(r).simulate("click");case 2:case"end":return t.stop()}}),t)}))));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),o.submit=function(){var t=i(s.mark((function t(r){var n=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r="form"),t.next=3,e.act(i(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.getComponent(r).simulate("submit"),t.next=4,n.refresh();case 4:case"end":return t.stop()}}),t)}))));case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),o.mount=function(){var t=i(s.mark((function t(e){var r,o,i,a,c,f,h;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:void 0===e&&(e={}),r=this.config.getValidHooks("onBeforeMount"),o=u(r);case 3:if((i=o()).done){t.next=9;break}return a=i.value,t.next=7,a.onBeforeMount(this,e);case 7:t.next=3;break;case 9:if(!this.onBeforeMount){t.next=12;break}return t.next=12,this.onBeforeMount(this);case 12:return t.next=14,p(this,this.props);case 14:return c=t.sent,f=this.initialMount||n.createElement(this.TestedComponent,Object.assign({},c)),h=this.getWrappers().reduce((function(t,e){var r=!1!==e.renderChildren&&t;return e.props?n.createElement(e.component,Object.assign({},e.props),r):t}),f),t.next=19,this.config.enzyme.mount(h);case 19:if(this.wrapper=t.sent,!1===e.async){t.next=28;break}if(!this.instance||"function"!=typeof this.instance.componentDidMount){t.next=24;break}return t.next=24,this.instance.componentDidMount();case 24:return t.next=26,m();case 26:return t.next=28,this.refresh();case 28:return t.abrupt("return",this);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),(r=[{key:"instance",get:function(){return f(this.component)}},{key:"component",get:function(){return this.wrapper.find(this.TestedComponent)}}])&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(t.prototype,r),t}(),x=new(function(){function t(t){this.hooks={},this.Tester=t,t.Configuration=this}var e=t.prototype;return e.configure=function(t,e){var r=this;return this.enzyme=t,e.hooks&&e.hooks.forEach((function(t){r.registerHook(t)})),this.Tester},e.registerHook=function(t){if(!t.name)throw new Error("Tester.registerHook() : A hooks must have a name.");if(this.hooks[t.name])throw new Error('Tester.registerHook() : A hook named "'+t.name+'" already exist.');this.hooks[t.name]=t},e.getValidHooks=function(t){var e=[];return Object.values(this.hooks).forEach((function(r){var n=!0;t&&!r[t]&&(n=!1),n&&e.push(r)})),e},t}())(w);exports.Tester=w,exports.TesterConfig=x,exports.flushPromises=m,exports.getInstance=f,exports.getValue=p,exports.isFunction=h,exports.isString=d,exports.sleep=l; | ||
//# sourceMappingURL=tester.cjs.production.min.js.map |
@@ -31,5 +31,5 @@ import React, { ComponentType } from 'react'; | ||
private getComponent; | ||
changeInput(selector: ISelectArg, value: string): void; | ||
checkBox(selector: ISelectArg, checked?: boolean): void; | ||
click(selector: ISelectArg): void; | ||
changeInput(selector: ISelectArg, value: string): Promise<void>; | ||
checkBox(selector: ISelectArg, checked?: boolean): Promise<void>; | ||
click(selector: ISelectArg): Promise<void>; | ||
submit(selector?: ISelectArg): Promise<void>; | ||
@@ -36,0 +36,0 @@ mount(mountOpts?: { |
@@ -0,1 +1,2 @@ | ||
import { act } from 'react-dom/test-utils'; | ||
import React, { Fragment } from 'react'; | ||
@@ -875,3 +876,3 @@ | ||
if (ms === void 0) { | ||
ms = 0; | ||
ms = 1; | ||
} | ||
@@ -1068,37 +1069,146 @@ | ||
_proto.changeInput = function changeInput(selector, value) { | ||
var component = this.getComponent(selector); | ||
component.simulate('focus'); | ||
component.simulate('change', { | ||
target: { | ||
value: value | ||
} | ||
}); | ||
component.simulate('blur'); | ||
}; | ||
_proto.changeInput = /*#__PURE__*/function () { | ||
var _changeInput = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(selector, value) { | ||
var _this3 = this; | ||
_proto.checkBox = function checkBox(selector, checked) { | ||
if (checked === void 0) { | ||
checked = true; | ||
return runtime_1.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context4.next = 2; | ||
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() { | ||
var component; | ||
return runtime_1.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
component = _this3.getComponent(selector); | ||
component.simulate('focus'); | ||
component.simulate('change', { | ||
target: { | ||
value: value | ||
} | ||
}); | ||
component.simulate('blur'); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3); | ||
}))); | ||
case 2: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
function changeInput(_x3, _x4) { | ||
return _changeInput.apply(this, arguments); | ||
} | ||
var component = this.getComponent(selector); | ||
component.simulate('change', { | ||
target: { | ||
checked: checked | ||
} | ||
}); | ||
}; | ||
return changeInput; | ||
}(); | ||
_proto.click = function click(selector) { | ||
var component = this.getComponent(selector); | ||
component.simulate('click'); | ||
}; | ||
_proto.checkBox = /*#__PURE__*/function () { | ||
var _checkBox = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(selector, checked) { | ||
var _this4 = this; | ||
return runtime_1.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
if (checked === void 0) { | ||
checked = true; | ||
} | ||
_context6.next = 3; | ||
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() { | ||
var component; | ||
return runtime_1.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
component = _this4.getComponent(selector); | ||
component.simulate('change', { | ||
target: { | ||
checked: checked | ||
} | ||
}); | ||
case 2: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee5); | ||
}))); | ||
case 3: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee6); | ||
})); | ||
function checkBox(_x5, _x6) { | ||
return _checkBox.apply(this, arguments); | ||
} | ||
return checkBox; | ||
}(); | ||
_proto.click = /*#__PURE__*/function () { | ||
var _click = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(selector) { | ||
var _this5 = this; | ||
return runtime_1.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() { | ||
var component; | ||
return runtime_1.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
component = _this5.getComponent(selector); | ||
component.simulate('click'); | ||
case 2: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7); | ||
}))); | ||
case 2: | ||
case "end": | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee8); | ||
})); | ||
function click(_x7) { | ||
return _click.apply(this, arguments); | ||
} | ||
return click; | ||
}(); | ||
_proto.submit = /*#__PURE__*/function () { | ||
var _submit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(selector) { | ||
var component; | ||
return runtime_1.wrap(function _callee3$(_context3) { | ||
var _submit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(selector) { | ||
var _this6 = this; | ||
return runtime_1.wrap(function _callee10$(_context10) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
@@ -1109,16 +1219,31 @@ if (selector === void 0) { | ||
component = this.getComponent(selector); | ||
component.simulate('submit'); | ||
_context3.next = 5; | ||
return this.refresh(); | ||
_context10.next = 3; | ||
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() { | ||
var component; | ||
return runtime_1.wrap(function _callee9$(_context9) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
component = _this6.getComponent(selector); | ||
component.simulate('submit'); | ||
_context9.next = 4; | ||
return _this6.refresh(); | ||
case 5: | ||
case 4: | ||
case "end": | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee9); | ||
}))); | ||
case 3: | ||
case "end": | ||
return _context3.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
}, _callee10); | ||
})); | ||
function submit(_x3) { | ||
function submit(_x8) { | ||
return _submit.apply(this, arguments); | ||
@@ -1131,8 +1256,8 @@ } | ||
_proto.mount = /*#__PURE__*/function () { | ||
var _mount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(mountOpts) { | ||
var _mount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(mountOpts) { | ||
var validHooks, _iterator, _step, hook, props, initialMount, WrapperTree; | ||
return runtime_1.wrap(function _callee4$(_context4) { | ||
return runtime_1.wrap(function _callee11$(_context11) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
@@ -1148,3 +1273,3 @@ if (mountOpts === void 0) { | ||
if ((_step = _iterator()).done) { | ||
_context4.next = 9; | ||
_context11.next = 9; | ||
break; | ||
@@ -1154,7 +1279,7 @@ } | ||
hook = _step.value; | ||
_context4.next = 7; | ||
_context11.next = 7; | ||
return hook.onBeforeMount(this, mountOpts); | ||
case 7: | ||
_context4.next = 3; | ||
_context11.next = 3; | ||
break; | ||
@@ -1164,15 +1289,15 @@ | ||
if (!this.onBeforeMount) { | ||
_context4.next = 12; | ||
_context11.next = 12; | ||
break; | ||
} | ||
_context4.next = 12; | ||
_context11.next = 12; | ||
return this.onBeforeMount(this); | ||
case 12: | ||
_context4.next = 14; | ||
_context11.next = 14; | ||
return getValue(this, this.props); | ||
case 14: | ||
props = _context4.sent; | ||
props = _context11.sent; | ||
initialMount = this.initialMount || React.createElement(this.TestedComponent, Object.assign({}, props)); | ||
@@ -1188,10 +1313,10 @@ WrapperTree = this.getWrappers().reduce(function (Tree, wrapper) { | ||
}, initialMount); | ||
_context4.next = 19; | ||
_context11.next = 19; | ||
return this.config.enzyme.mount(WrapperTree); | ||
case 19: | ||
this.wrapper = _context4.sent; | ||
this.wrapper = _context11.sent; | ||
if (!(mountOpts.async !== false)) { | ||
_context4.next = 28; | ||
_context11.next = 28; | ||
break; | ||
@@ -1201,29 +1326,29 @@ } | ||
if (!(this.instance && typeof this.instance.componentDidMount === 'function')) { | ||
_context4.next = 24; | ||
_context11.next = 24; | ||
break; | ||
} | ||
_context4.next = 24; | ||
_context11.next = 24; | ||
return this.instance.componentDidMount(); | ||
case 24: | ||
_context4.next = 26; | ||
_context11.next = 26; | ||
return flushPromises(); | ||
case 26: | ||
_context4.next = 28; | ||
_context11.next = 28; | ||
return this.refresh(); | ||
case 28: | ||
return _context4.abrupt("return", this); | ||
return _context11.abrupt("return", this); | ||
case 29: | ||
case "end": | ||
return _context4.stop(); | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
}, _callee11, this); | ||
})); | ||
function mount(_x4) { | ||
function mount(_x9) { | ||
return _mount.apply(this, arguments); | ||
@@ -1230,0 +1355,0 @@ } |
{ | ||
"name": "@mighty-justice/tester", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Bootstrap your tests!", | ||
@@ -66,2 +66,3 @@ "main": "dist/index.js", | ||
"@types/react": "^16.9.49", | ||
"@types/react-dom": "^17.0.10", | ||
"babel-jest": "^26.3.0", | ||
@@ -72,4 +73,4 @@ "coveralls": "^3.1.0", | ||
"np": "^5.0.0", | ||
"react": "^16.13.1", | ||
"react-dom": ">=16.13.1", | ||
"react": "^16", | ||
"react-dom": "^16", | ||
"source-map-explorer": "^2.5.0", | ||
@@ -76,0 +77,0 @@ "tsdx": "^0.14.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
284205
2584
3
15