Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@enact/core

Package Overview
Dependencies
Maintainers
1
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enact/core - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [4.1.3] - 2022-03-07
No significant changes.
## [4.1.2] - 2021-12-22

@@ -7,0 +11,0 @@

19

dispatcher/tests/dispatcher-specs.js

@@ -12,4 +12,3 @@ "use strict";

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -23,4 +22,3 @@ test('should not register duplicate handlers on target', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -35,4 +33,3 @@ test('should unregister handlers on target', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -46,4 +43,3 @@ test('should only call a "once" handler once', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -56,5 +52,3 @@ test('should allow unregistering a "once" before it is called', function () {

window.dispatchEvent(ev);
var expected = 0;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).not.toHaveBeenCalled();
});

@@ -77,5 +71,4 @@ test('should not block subsequent handlers when a handler throws', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});
});

@@ -32,4 +32,3 @@ "use strict";

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -41,5 +40,5 @@ test('should call multiple handlers', function () {

callback(makeEvent());
var expected = true;
var actual = handler1.mock.calls.length === 1 && handler2.mock.calls.length === 1;
expect(actual).toBe(expected);
var expected = 1;
expect(handler1).toHaveBeenCalledTimes(expected);
expect(handler2).toHaveBeenCalledTimes(expected);
});

@@ -51,4 +50,3 @@ test('should skip non-function handlers', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -60,5 +58,5 @@ test('should not call handlers after one that returns false', function () {

callback(makeEvent());
var expected = 0;
var actual = handler2.mock.calls.length;
expect(actual).toBe(expected);
var expectedFirst = 1;
expect(handler1).toHaveBeenCalledTimes(expectedFirst);
expect(handler2).not.toHaveBeenCalled();
});

@@ -70,4 +68,4 @@ test('should call stopPropagation on event', function () {

var expected = 1;
var actual = ev.stopPropagation.mock.calls.length;
expect(actual).toBe(expected);
var actual = ev.stopPropagation;
expect(actual).toHaveBeenCalledTimes(expected);
});

@@ -79,4 +77,4 @@ test('should call preventDefault on event', function () {

var expected = 1;
var actual = ev.preventDefault.mock.calls.length;
expect(actual).toBe(expected);
var actual = ev.preventDefault;
expect(actual).toHaveBeenCalledTimes(expected);
});

@@ -90,4 +88,4 @@ test('should call any method on event', function () {

var expected = 1;
var actual = ev.customMethod.mock.calls.length;
expect(actual).toBe(expected);
var actual = ev.customMethod;
expect(actual).toHaveBeenCalledTimes(expected);
});

@@ -106,5 +104,5 @@ test('should only call handler for specified keyCode', function () {

test('should only call handler for specified event prop', function () {
var handler = jest.fn();
var prop = 'index';
var value = 0;
var handler = jest.fn();
var callback = (0, _handle.handle)((0, _handle.forEventProp)(prop, value), handler); // undefined shouldn't pass

@@ -212,4 +210,3 @@

var expected = 1;
var actual = finallyCallback.mock.calls.length;
expect(actual).toBe(expected);
expect(finallyCallback).toHaveBeenCalledTimes(expected);
});

@@ -221,4 +218,3 @@ test('should call the finally callback when handle returns false', function () {

var expected = 1;
var actual = finallyCallback.mock.calls.length;
expect(actual).toBe(expected);
expect(finallyCallback).toHaveBeenCalledTimes(expected);
});

@@ -237,4 +233,3 @@ test('should call the finally callback when handle throws an error', function () {

var expected = 1;
var actual = finallyCallback.mock.calls.length;
expect(actual).toBe(expected);
expect(finallyCallback).toHaveBeenCalledTimes(expected);
});

@@ -250,4 +245,3 @@ });

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -259,4 +253,3 @@ test('should stop if the first handler passes', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -363,4 +356,3 @@ test('should pass args to condition', function () {

var expected = 1;
var actual = handler.mock.calls.length;
expect(actual).toBe(expected);
expect(handler).toHaveBeenCalledTimes(expected);
});

@@ -367,0 +359,0 @@ });

@@ -12,3 +12,4 @@ // Type definitions for core/hoc

* * an instance config only and return a decorator function expecting a component constructor
(like the next bullet), or
*
* (like the next bullet), or
* * a component constructor and return a renderable component

@@ -15,0 +16,0 @@ *

"use strict";
var _enzyme = require("enzyme");
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _hoc = _interopRequireDefault(require("../hoc"));

@@ -18,2 +20,4 @@

describe('hoc', function () {
var data;
var testID = 'test-HoC';
var defaultConfig = {

@@ -23,4 +27,7 @@ color: 'blue'

var HoC = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
data = Wrapped;
return function (props) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, props), config));
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread(_objectSpread({}, props), config), {}, {
"data-testid": testID
}));
};

@@ -30,3 +37,5 @@ });

return function () {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, config));
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, config), {}, {
"data-testid": testID
}));
};

@@ -37,9 +46,14 @@ });

return function () {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, config));
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, config), {}, {
"data-testid": testID
}));
};
});
var Component = ImplicitNullHoC('span');
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'span';
var actual = subject.name();
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expected = 'SPAN';
var actual = component.nodeName;
expect(actual).toBe(expected);

@@ -49,5 +63,8 @@ });

var Component = HoC('span');
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'span';
var actual = subject.name();
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expected = 'SPAN';
var actual = component.nodeName;
expect(actual).toBe(expected);

@@ -57,17 +74,27 @@ });

function Thing() {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
"data-testid": testID
});
}
var Component = HoC(Thing);
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'Thing';
var actual = subject.name();
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expected = 'DIV';
var actual = component.nodeName;
var actualWrapped = data;
expect(actual).toBe(expected);
expect(actualWrapped).toBe(Thing);
});
test('should use default config when instance config is omitted', function () {
var Component = HoC('span');
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = defaultConfig.color;
var actual = subject.find('span').prop('color');
expect(actual).toBe(expected);
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expectedAttribute = 'color';
var expectedValue = defaultConfig.color;
expect(component).toHaveAttribute(expectedAttribute, expectedValue);
});

@@ -79,13 +106,20 @@ test('should overwrite default config with instance config', function () {

var Component = HoC(instanceConfig, 'div');
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = instanceConfig.color;
var actual = subject.find('div').prop('color');
expect(actual).toBe(expected);
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expectedAttribute = 'color';
var expectedValue = instanceConfig.color;
expect(component).toHaveAttribute(expectedAttribute, expectedValue);
});
test('should allow construction without default or instance configs', function () {
var Component = NullHoC('div');
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 1;
var actual = subject.find('div').length;
var Component = NullHoC('input');
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expected = 'INPUT';
var actual = component.nodeName;
expect(actual).toBe(expected);
expect(component).toBeInTheDocument();
});

@@ -97,7 +131,10 @@ test('should allow construction without default config', function () {

var Component = NullHoC(instanceConfig, 'div');
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = instanceConfig.color;
var actual = subject.find('div').prop('color');
expect(actual).toBe(expected);
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var component = _react.screen.getByTestId(testID);
var expectedAttribute = 'color';
var expectedValue = instanceConfig.color;
expect(component).toHaveAttribute(expectedAttribute, expectedValue);
});
});
"use strict";
var _react = require("react");
var _react = require("@testing-library/react");
var _enzyme = require("enzyme");
var _react2 = require("react");

@@ -36,2 +36,3 @@ var _ApiDecorator = _interopRequireDefault(require("../ApiDecorator"));

var data = [];
var ApiProvider = (_temp = _class = /*#__PURE__*/function (_ReactComponent) {

@@ -66,2 +67,7 @@ _inherits(ApiProvider, _ReactComponent);

value: function render() {
data = {
arrowFunction: this.arrowFunction,
instanceFunction: this.instanceFunction,
instanceProperty: this.instanceProperty
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});

@@ -72,3 +78,3 @@ }

return ApiProvider;
}(_react.Component), _class.displayName = 'ApiProvider', _temp);
}(_react2.Component), _class.displayName = 'ApiProvider', _temp);
test('should invoke arrow function on wrapped component', function () {

@@ -78,5 +84,5 @@ var Component = (0, _ApiDecorator["default"])({

}, ApiProvider);
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'arrow';
var actual = subject.instance().arrowFunction();
var actual = data.arrowFunction();
expect(actual).toBe(expected);

@@ -88,5 +94,5 @@ });

}, ApiProvider);
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'instance';
var actual = subject.instance().instanceFunction();
var actual = data.instanceFunction();
expect(actual).toBe(expected);

@@ -98,5 +104,5 @@ });

}, ApiProvider);
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'property';
var actual = subject.instance().instanceProperty;
var actual = data.instanceProperty;
expect(actual).toBe(expected);

@@ -108,8 +114,8 @@ });

}, ApiProvider);
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
subject.instance().instanceProperty = 'updated';
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
data.instanceProperty = 'updated';
var expected = 'updated';
var actual = subject.instance().instanceProperty;
var actual = data.instanceProperty;
expect(actual).toBe(expected);
});
});

@@ -5,4 +5,8 @@ "use strict";

var _enzyme = require("enzyme");
require("@testing-library/jest-dom");
var _react2 = require("@testing-library/react");
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _Registry = _interopRequireDefault(require("../Registry"));

@@ -148,73 +152,95 @@

test('should increment child on click', function () {
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
id: "a-btn",
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
"data-testid": "a-btn",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "a"
"data-testid": "a"
})
}));
RegistryApp.find('button#a-btn').simulate('click');
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
var expected = '1';
var actual = RegistryApp.find('div#a').text();
expect(expected).toBe(actual);
var child = _react2.screen.getByTestId('a');
expect(child).toHaveTextContent(expected);
});
test('should increment both children on top click', function () {
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
id: "a-btn",
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
"data-testid": "a-btn",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "a"
"data-testid": "a"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
id: "b-btn",
"data-testid": "b-btn",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "b"
"data-testid": "b"
})
})]
}));
RegistryApp.find('button#a-btn').simulate('click');
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
var expected = '1';
var actualA = RegistryApp.find('div#a').text();
var actualB = RegistryApp.find('div#b').text();
expect(expected).toBe(actualA);
expect(expected).toBe(actualB);
var childA = _react2.screen.getByTestId('a');
var childB = _react2.screen.getByTestId('b');
expect(childA).toHaveTextContent(expected);
expect(childB).toHaveTextContent(expected);
});
test('should increment the deepest child when we click child button', function () {
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
id: "a-btn",
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
"data-testid": "a-btn",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "a"
"data-testid": "a"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
id: "b-btn",
"data-testid": "b-btn",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "b"
"data-testid": "b"
})
})]
}));
RegistryApp.find('button#b-btn').simulate('click');
_userEvent["default"].click(_react2.screen.getByTestId('b-btn'));
var expectedA = '0';
var expectedB = '1';
var actualA = RegistryApp.find('div#a').text();
var actualB = RegistryApp.find('div#b').text();
expect(expectedA).toBe(actualA);
expect(expectedB).toBe(actualB);
var childA = _react2.screen.getByTestId('a');
var childB = _react2.screen.getByTestId('b');
expect(childA).toHaveTextContent(expectedA);
expect(childB).toHaveTextContent(expectedB);
});
test('should support removing children without error', function () {
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
id: "a-btn",
var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
"data-testid": "a-btn",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "a"
"data-testid": "a"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "b"
"data-testid": "b"
})]
}));
RegistryApp.find('button#a-btn').simulate('click'); // changing children should be safe and not throw errors when notifying instances
})),
rerender = _render.rerender;
RegistryApp.setProps({
_userEvent["default"].click(_react2.screen.getByTestId('a-btn')); // changing children should be safe and not throw errors when notifying instances
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
"data-testid": "a-btn",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
id: "c"
"data-testid": "c"
})
});
RegistryApp.find('button#a-btn').simulate('click');
}));
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
var expectedC = '1';
var actualC = RegistryApp.find('div#c').text();
expect(expectedC).toBe(actualC);
var childC = _react2.screen.getByTestId('c');
expect(childC).toHaveTextContent(expectedC);
});
});
"use strict";
var _react = require("react");
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _enzyme = require("enzyme");
var _react2 = require("react");

@@ -38,3 +42,3 @@ var _kind = _interopRequireDefault(require("../kind"));

describe('kind', function () {
var TestContext = /*#__PURE__*/(0, _react.createContext)({
var TestContext = /*#__PURE__*/(0, _react2.createContext)({
value: 'initial'

@@ -77,4 +81,4 @@ });

return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
"data-context": contextValue,
title: label,
"data-context": contextValue,
children: value

@@ -93,8 +97,12 @@ }));

render: function render() {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
"data-testid": "minimal"
});
}
});
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Minimal, {}));
var actual = subject.find('div');
expect(actual).toBeDefined();
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Minimal, {}));
var minimalDiv = _react.screen.queryByTestId('minimal');
expect(minimalDiv).toBeInTheDocument();
});

@@ -113,4 +121,4 @@ test('should default {label} property', function () {

var subject = /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
prop: 1,
label: undefined
label: undefined,
prop: 1
});

@@ -122,24 +130,32 @@ var expected = 'Label';

test('should add className defined in styles', function () {
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
prop: 1
}));
var expected = 'kind';
var actual = subject.find('div').prop('className');
expect(actual).toBe(expected);
var kindDiv = _react.screen.getByTitle('Label');
expect(kindDiv).toHaveClass(expected);
});
test('should compute {value} property', function () {
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
prop: 1
}));
var expected = 2;
var actual = subject.find('div').prop('children');
expect(actual).toBe(expected);
var expected = '2';
var kindDiv = _react.screen.getByTitle('Label');
expect(kindDiv).toHaveTextContent(expected);
});
test('should support contextType in handlers', function () {
var onClick = jest.fn();
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
prop: 1,
onClick: onClick
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
onClick: onClick,
prop: 1
}));
subject.find('div').invoke('onClick')();
var kindDiv = _react.screen.getByTitle('Label');
_userEvent["default"].click(kindDiv);
var expected = 'initial';

@@ -150,8 +166,10 @@ var actual = onClick.mock.calls[0][0];

test('should support contextType in computed', function () {
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
prop: 1
}));
var expected = 'contextinitial';
var actual = subject.find('div').prop('data-context');
expect(actual).toBe(expected);
var kindDiv = _react.screen.getByTitle('Label');
expect(kindDiv).toHaveAttribute('data-context', expected);
});

@@ -164,3 +182,3 @@ test('support using hooks within kind instances', function () {

// eslint-disable-next-line react-hooks/rules-of-hooks
var _useState = (0, _react.useState)(0),
var _useState = (0, _react2.useState)(0),
_useState2 = _slicedToArray(_useState, 2),

@@ -171,2 +189,3 @@ state = _useState2[0],

return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
"data-testid": "button",
onClick: function onClick() {

@@ -179,7 +198,10 @@ return setState(state + 1);

});
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {}));
subject.find('button').invoke('onClick')();
var expected = 1;
var actual = subject.find('button').prop('children');
expect(actual).toBe(expected);
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {}));
var button = _react.screen.getByTestId('button');
_userEvent["default"].click(button);
var expected = '1';
expect(button).toHaveTextContent(expected);
});

@@ -186,0 +208,0 @@ describe('inline', function () {

{
"name": "@enact/core",
"version": "4.1.2",
"version": "4.1.3",
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",

@@ -28,11 +28,11 @@ "main": "index.js",

"dependencies": {
"classnames": "^2.2.5",
"invariant": "^2.2.2",
"prop-types": "^15.7.2",
"ramda": "^0.24.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-is": "^17.0.1",
"classnames": "^2.3.1",
"invariant": "^2.2.4",
"prop-types": "^15.8.0",
"ramda": "^0.27.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"warning": "^4.0.3"
}
}

@@ -27,3 +27,3 @@ # @enact/core [![npm (scoped)](https://img.shields.io/npm/v/@enact/core.svg?style=flat-square)](https://www.npmjs.com/package/@enact/core)

Copyright (c) 2012-2021 LG Electronics
Copyright (c) 2012-2022 LG Electronics

@@ -30,0 +30,0 @@ Unless otherwise specified or set forth in the NOTICE file, all content, including all source code files and documentation files in this repository are: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this content except in compliance with the License. You may obtain a copy of the License at

@@ -19,5 +19,7 @@ // Type definitions for core/snapshot

* * The callback should not alter the initial HTML state. If it does, it will invalidate the
pre-render state and interfere with React rehydration.
*
* pre-render state and interfere with React rehydration.
* * The callback should be limited to module-scoped actions and not component instance actions. If
the action is tied to a component, it should be invoked from within the component's lifecycle
*
* the action is tied to a component, it should be invoked from within the component's lifecycle
methods.

@@ -24,0 +26,0 @@ */

"use strict";
var _enzyme = require("enzyme");
require("@testing-library/jest-dom");
var _react = require("react");
var _react = require("@testing-library/react");
var _react2 = require("react");
var _useChainRefs = _interopRequireDefault(require("../useChainRefs"));

@@ -36,3 +38,3 @@

var ref = jest.fn();
(0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
refs: [ref]

@@ -43,4 +45,4 @@ }));

test('should call a single object ref', function () {
var ref = /*#__PURE__*/(0, _react.createRef)();
(0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
var ref = /*#__PURE__*/(0, _react2.createRef)();
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
refs: [ref]

@@ -55,3 +57,3 @@ }));

var ref = jest.fn();
(0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
refs: [invalid, ref]

@@ -58,0 +60,0 @@ }));

"use strict";
var _enzyme = require("enzyme");
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _useClass = _interopRequireDefault(require("../useClass"));

@@ -23,4 +25,5 @@

return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
fromProps: props.arg,
fromClass: instance.arg
"data-testid": "div",
"data-fromclass": instance.arg,
"data-fromprops": props.arg
});

@@ -31,23 +34,29 @@ }

var arg = 'arg';
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
arg: arg
}));
var expected = arg;
var actual = subject.prop('fromClass');
expect(actual).toBe(expected);
var div = _react.screen.getByTestId('div');
expect(div).toHaveAttribute('data-fromclass', arg);
});
test('should use the same instance of Class across renders', function () {
var arg = 'arg';
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
arg: arg
}));
expect(subject.prop('fromProps')).toBe(arg);
subject.setProps({
arg: 'changed'
}); // verify that the children still reflects the class value set at construction but the prop
})),
rerender = _render.rerender;
var div = _react.screen.getByTestId('div');
expect(div).toHaveAttribute('data-fromprops', arg);
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
arg: "changed"
})); // verify that the children still reflects the class value set at construction but the prop
// value was updated when props were updated
expect(subject.prop('fromClass')).toBe(arg);
expect(subject.prop('fromProps')).toBe('changed');
expect(div).toHaveAttribute('data-fromclass', arg);
expect(div).toHaveAttribute('data-fromprops', 'changed');
});
});
"use strict";
var _enzyme = require("enzyme");
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _useHandlers = _interopRequireDefault(require("../useHandlers"));

@@ -18,2 +20,3 @@

describe('useHandlers', function () {
var data = {};
var context = {

@@ -29,3 +32,8 @@ value: 1

}, props, context);
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), handlers));
data = {
handlers: handlers
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
"data-testid": "divComponent"
}));
} // Sanity test for Component moreso than useHandlers test

@@ -35,12 +43,13 @@

test('should include handlers in props', function () {
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = 'testEvent';
var actual = subject.props();
expect(actual).toHaveProperty(expected);
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var actual = data.handlers.testEvent;
expect(actual).toBeDefined();
});
test('should have the same reference across renders', function () {
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var expected = subject.prop('testEvent');
subject.setProps({});
var actual = subject.prop('testEvent');
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
rerender = _render.rerender;
var expected = data.handlers.testEvent;
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var actual = data.handlers.testEvent;
expect(actual).toBe(expected);

@@ -50,8 +59,10 @@ });

var spy = jest.fn();
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var props = {
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
rerender = _render2.rerender;
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
children: 'updated'
};
subject.setProps(props);
subject.find('div').invoke('testEvent')(spy);
}));
data.handlers.testEvent(spy);
expect(spy).toHaveBeenCalled();

@@ -61,9 +72,13 @@ });

var spy = jest.fn();
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var props = {
var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
rerender = _render3.rerender;
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
children: 'updated'
}));
data.handlers.testEvent(spy);
var expected = {
children: 'updated'
};
subject.setProps(props);
subject.find('div').invoke('testEvent')(spy);
var expected = props;
var actual = spy.mock.calls[0][0];

@@ -74,4 +89,4 @@ expect(actual).toMatchObject(expected);

var spy = jest.fn();
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
subject.find('div').invoke('testEvent')(spy); // defined a "global" context to ease testability but this isn't representative of the
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
data.handlers.testEvent(spy); // defined a "global" context to ease testability but this isn't representative of the
// expected use case of this feature.

@@ -87,10 +102,9 @@

});
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var returnValue = subject.find('div').invoke('testEvent')(spy); // defined a "global" context to ease testability but this isn't representative of the
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
var returnValue = data.handlers.testEvent(spy); // defined a "global" context to ease testability but this isn't representative of the
// expected use case of this feature.
var expected = 'ok';
var actual = returnValue;
expect(actual).toBe(expected);
expect(returnValue).toBe(expected);
});
});

@@ -11,6 +11,6 @@ // Type definitions for core/util

export declare class Job {
constructor(
/**
* Function to execute as the requested job.
*/
constructor
/**
* Function to execute as the requested job.
*/(
fn: Function

@@ -17,0 +17,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc