@instructure/ui-testable
Advanced tools
Comparing version 5.41.0-rc.12 to 5.41.0-rc.13
@@ -6,4 +6,4 @@ # Change Log | ||
<a name="5.41.0-rc.12"></a> | ||
# [5.41.0-rc.12](https://github.com/instructure/instructure-ui/compare/v5.40.0...v5.41.0-rc.12) (2019-01-22) | ||
<a name="5.41.0-rc.13"></a> | ||
# [5.41.0-rc.13](https://github.com/instructure/instructure-ui/compare/v5.40.0...v5.41.0-rc.13) (2019-01-25) | ||
@@ -10,0 +10,0 @@ **Note:** Version bump only for package @instructure/ui-testable |
@@ -1,6 +0,8 @@ | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _get from 'babel-runtime/helpers/get'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; | ||
import _get from "@babel/runtime/helpers/get"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
/* | ||
@@ -29,10 +31,5 @@ * The MIT License (MIT) | ||
*/ | ||
import { findDOMNode } from 'react-dom'; | ||
import decorator from '@instructure/ui-decorator'; | ||
export default decorator(function (ComposedComponent) { | ||
var _class, _temp; | ||
var displayName = ComposedComponent.displayName || ComposedComponent.name; | ||
@@ -43,4 +40,7 @@ var locator = { | ||
}; | ||
var selector = '[' + locator.attribute + '~="' + locator.value + '"]'; | ||
var TestableComponent = (_temp = _class = function (_ComposedComponent) { | ||
var selector = "[".concat(locator.attribute, "~=\"").concat(locator.value, "\"]"); | ||
var TestableComponent = | ||
/*#__PURE__*/ | ||
function (_ComposedComponent) { | ||
_inherits(TestableComponent, _ComposedComponent); | ||
@@ -51,70 +51,79 @@ | ||
return _possibleConstructorReturn(this, (TestableComponent.__proto__ || Object.getPrototypeOf(TestableComponent)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(TestableComponent).apply(this, arguments)); | ||
} | ||
_createClass(TestableComponent, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
if (_get(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidMount', this)) { | ||
if (_get(_getPrototypeOf(TestableComponent.prototype), "componentDidMount", this)) { | ||
var _get2; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
(_get2 = _get(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidMount', this)).call.apply(_get2, [this].concat(args)); | ||
(_get2 = _get(_getPrototypeOf(TestableComponent.prototype), "componentDidMount", this)).call.apply(_get2, [this].concat(args)); | ||
} | ||
this.appendLocatorAttribute(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
if (_get(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidUpdate', this)) { | ||
if (_get(_getPrototypeOf(TestableComponent.prototype), "componentDidUpdate", this)) { | ||
var _get3; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
(_get3 = _get(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidUpdate', this)).call.apply(_get3, [this].concat(args)); | ||
(_get3 = _get(_getPrototypeOf(TestableComponent.prototype), "componentDidUpdate", this)).call.apply(_get3, [this].concat(args)); | ||
} | ||
this.appendLocatorAttribute(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
this._testableUnmounted = true; | ||
if (_get(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentWillUnmount', this)) { | ||
if (_get(_getPrototypeOf(TestableComponent.prototype), "componentWillUnmount", this)) { | ||
var _get4; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
(_get4 = _get(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentWillUnmount', this)).call.apply(_get4, [this].concat(args)); | ||
(_get4 = _get(_getPrototypeOf(TestableComponent.prototype), "componentWillUnmount", this)).call.apply(_get4, [this].concat(args)); | ||
} | ||
clearTimeout(this.locatorTimeout); | ||
} | ||
}, { | ||
key: 'appendLocatorAttribute', | ||
key: "appendLocatorAttribute", | ||
value: function appendLocatorAttribute() { | ||
var _this2 = this; | ||
var _this = this; | ||
this.locatorTimeout = setTimeout(function () { | ||
var node = void 0; | ||
if (_this2._testableUnmounted) { | ||
var node; | ||
if (_this._testableUnmounted) { | ||
return; | ||
} | ||
try { | ||
// Use this.DOMNode for components that render as non-native Portals... | ||
node = findDOMNode(_this2) || _this2.DOMNode; | ||
node = findDOMNode(_this) || _this.DOMNode; | ||
} catch (e) { | ||
console.warn('[ui-testable] Could not append locator attribute: ' + e); | ||
console.warn("[ui-testable] Could not append locator attribute: ".concat(e)); | ||
} | ||
if (node && node.getAttribute) { | ||
var attribute = node.getAttribute(locator.attribute); | ||
var values = typeof attribute === 'string' ? attribute.split(/\s+/) : []; | ||
if (!values.includes(locator.value)) { | ||
values.push(locator.value); | ||
} | ||
node.setAttribute(locator.attribute, values.join(' ')); | ||
@@ -127,5 +136,6 @@ } | ||
return TestableComponent; | ||
}(ComposedComponent), _class.selector = selector, _temp); | ||
}(ComposedComponent); | ||
TestableComponent.selector = selector; | ||
return TestableComponent; | ||
}); |
105
lib/index.js
@@ -1,35 +0,26 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _get5 = _interopRequireDefault(require("@babel/runtime/helpers/get")); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _get5 = require('babel-runtime/helpers/get'); | ||
var _reactDom = require("react-dom"); | ||
var _get6 = _interopRequireDefault(_get5); | ||
var _uiDecorator = _interopRequireDefault(require("@instructure/ui-decorator")); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _reactDom = require('react-dom'); | ||
var _uiDecorator = require('@instructure/ui-decorator'); | ||
var _uiDecorator2 = _interopRequireDefault(_uiDecorator); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* | ||
@@ -58,6 +49,3 @@ * The MIT License (MIT) | ||
*/ | ||
exports.default = (0, _uiDecorator2.default)(function (ComposedComponent) { | ||
var _class, _temp; | ||
var _default = (0, _uiDecorator.default)(function (ComposedComponent) { | ||
var displayName = ComposedComponent.displayName || ComposedComponent.name; | ||
@@ -68,76 +56,88 @@ var locator = { | ||
}; | ||
var selector = '[' + locator.attribute + '~="' + locator.value + '"]'; | ||
var TestableComponent = (_temp = _class = function (_ComposedComponent) { | ||
(0, _inherits3.default)(TestableComponent, _ComposedComponent); | ||
var selector = "[".concat(locator.attribute, "~=\"").concat(locator.value, "\"]"); | ||
var TestableComponent = | ||
/*#__PURE__*/ | ||
function (_ComposedComponent) { | ||
(0, _inherits2.default)(TestableComponent, _ComposedComponent); | ||
function TestableComponent() { | ||
(0, _classCallCheck3.default)(this, TestableComponent); | ||
return (0, _possibleConstructorReturn3.default)(this, (TestableComponent.__proto__ || Object.getPrototypeOf(TestableComponent)).apply(this, arguments)); | ||
(0, _classCallCheck2.default)(this, TestableComponent); | ||
return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(TestableComponent).apply(this, arguments)); | ||
} | ||
(0, _createClass3.default)(TestableComponent, [{ | ||
key: 'componentDidMount', | ||
(0, _createClass2.default)(TestableComponent, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
if ((0, _get6.default)(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidMount', this)) { | ||
if ((0, _get5.default)((0, _getPrototypeOf2.default)(TestableComponent.prototype), "componentDidMount", this)) { | ||
var _get2; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
(_get2 = (0, _get6.default)(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidMount', this)).call.apply(_get2, [this].concat(args)); | ||
(_get2 = (0, _get5.default)((0, _getPrototypeOf2.default)(TestableComponent.prototype), "componentDidMount", this)).call.apply(_get2, [this].concat(args)); | ||
} | ||
this.appendLocatorAttribute(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
if ((0, _get6.default)(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidUpdate', this)) { | ||
if ((0, _get5.default)((0, _getPrototypeOf2.default)(TestableComponent.prototype), "componentDidUpdate", this)) { | ||
var _get3; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
(_get3 = (0, _get6.default)(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentDidUpdate', this)).call.apply(_get3, [this].concat(args)); | ||
(_get3 = (0, _get5.default)((0, _getPrototypeOf2.default)(TestableComponent.prototype), "componentDidUpdate", this)).call.apply(_get3, [this].concat(args)); | ||
} | ||
this.appendLocatorAttribute(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
this._testableUnmounted = true; | ||
if ((0, _get6.default)(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentWillUnmount', this)) { | ||
if ((0, _get5.default)((0, _getPrototypeOf2.default)(TestableComponent.prototype), "componentWillUnmount", this)) { | ||
var _get4; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
(_get4 = (0, _get6.default)(TestableComponent.prototype.__proto__ || Object.getPrototypeOf(TestableComponent.prototype), 'componentWillUnmount', this)).call.apply(_get4, [this].concat(args)); | ||
(_get4 = (0, _get5.default)((0, _getPrototypeOf2.default)(TestableComponent.prototype), "componentWillUnmount", this)).call.apply(_get4, [this].concat(args)); | ||
} | ||
clearTimeout(this.locatorTimeout); | ||
} | ||
}, { | ||
key: 'appendLocatorAttribute', | ||
key: "appendLocatorAttribute", | ||
value: function appendLocatorAttribute() { | ||
var _this2 = this; | ||
var _this = this; | ||
this.locatorTimeout = setTimeout(function () { | ||
var node = void 0; | ||
if (_this2._testableUnmounted) { | ||
var node; | ||
if (_this._testableUnmounted) { | ||
return; | ||
} | ||
try { | ||
// Use this.DOMNode for components that render as non-native Portals... | ||
node = (0, _reactDom.findDOMNode)(_this2) || _this2.DOMNode; | ||
node = (0, _reactDom.findDOMNode)(_this) || _this.DOMNode; | ||
} catch (e) { | ||
console.warn('[ui-testable] Could not append locator attribute: ' + e); | ||
console.warn("[ui-testable] Could not append locator attribute: ".concat(e)); | ||
} | ||
if (node && node.getAttribute) { | ||
var attribute = node.getAttribute(locator.attribute); | ||
var values = typeof attribute === 'string' ? attribute.split(/\s+/) : []; | ||
if (!values.includes(locator.value)) { | ||
values.push(locator.value); | ||
} | ||
node.setAttribute(locator.attribute, values.join(' ')); | ||
@@ -149,5 +149,8 @@ } | ||
return TestableComponent; | ||
}(ComposedComponent), _class.selector = selector, _temp); | ||
}(ComposedComponent); | ||
TestableComponent.selector = selector; | ||
return TestableComponent; | ||
}); | ||
}); | ||
exports.default = _default; |
{ | ||
"name": "@instructure/ui-testable", | ||
"version": "5.41.0-rc.12", | ||
"version": "5.41.0-rc.13", | ||
"description": "A UI component test utility made by Instructure Inc.", | ||
@@ -24,8 +24,8 @@ "author": "Instructure, Inc. Engineering and Product Design", | ||
"devDependencies": { | ||
"@instructure/ui-babel-preset": "^5.41.0-rc.12", | ||
"@instructure/ui-test-utils": "^5.41.0-rc.12", | ||
"@instructure/ui-babel-preset": "^5.41.0-rc.13", | ||
"@instructure/ui-test-utils": "^5.41.0-rc.13", | ||
"prop-types": "^15.6.2" | ||
}, | ||
"dependencies": { | ||
"@instructure/ui-decorator": "^5.41.0-rc.12" | ||
"@instructure/ui-decorator": "^5.41.0-rc.13" | ||
}, | ||
@@ -40,3 +40,3 @@ "peerDependencies": { | ||
"sideEffects": false, | ||
"gitHead": "ef0a38f7dfea9d40129ce30dd68c99ce06d15fc6" | ||
"gitHead": "f8637e1c8ec55c1ec6d55dbbb30e143137a0c310" | ||
} |
311
19387