1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.expectNoHiddenParents = exports.flushPromises = exports.mockEvent = exports.renderIntoDocument = exports.mountAttached = exports.delay = exports.expectMissing = exports.expectOne = exports.expectNodes = exports.findNodes = void 0;
|
4 | var enzyme_1 = require("enzyme");
|
5 | var ReactDOM = require("react-dom");
|
6 | var ReactTestUtils = require("react-dom/test-utils");
|
7 | function findNodes(wrapper, className) {
|
8 | return wrapper.find(className).filterWhere(function (node) { return typeof node.type() === 'string'; });
|
9 | }
|
10 | exports.findNodes = findNodes;
|
11 | function expectNodes(wrapper, className, n) {
|
12 | expect(findNodes(wrapper, className).length).toEqual(n);
|
13 | }
|
14 | exports.expectNodes = expectNodes;
|
15 | function expectOne(wrapper, className) {
|
16 | expectNodes(wrapper, className, 1);
|
17 | }
|
18 | exports.expectOne = expectOne;
|
19 | function expectMissing(wrapper, className) {
|
20 | expectNodes(wrapper, className, 0);
|
21 | }
|
22 | exports.expectMissing = expectMissing;
|
23 |
|
24 | function delay(millisecond) {
|
25 | return new Promise(function (resolve) { return setTimeout(resolve, millisecond); });
|
26 | }
|
27 | exports.delay = delay;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | function mountAttached(element) {
|
34 | var parent = document.createElement('div');
|
35 | document.body.appendChild(parent);
|
36 | return enzyme_1.mount(element, { attachTo: parent });
|
37 | }
|
38 | exports.mountAttached = mountAttached;
|
39 | function renderIntoDocument(element) {
|
40 | var component = ReactTestUtils.renderIntoDocument(element);
|
41 | var renderedDOM = ReactDOM.findDOMNode(component);
|
42 | return renderedDOM;
|
43 | }
|
44 | exports.renderIntoDocument = renderIntoDocument;
|
45 | function mockEvent(targetValue) {
|
46 | if (targetValue === void 0) { targetValue = ''; }
|
47 | var target = { value: targetValue };
|
48 | return { target: target };
|
49 | }
|
50 | exports.mockEvent = mockEvent;
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | function flushPromises() {
|
56 |
|
57 | return new Promise(function (resolve) { return setImmediate(resolve); });
|
58 | }
|
59 | exports.flushPromises = flushPromises;
|
60 |
|
61 |
|
62 |
|
63 | function expectNoHiddenParents(element) {
|
64 | var el = element;
|
65 | while (el) {
|
66 | expect(el.getAttribute('aria-hidden')).not.toBe('true');
|
67 | el = el.parentElement;
|
68 | }
|
69 | }
|
70 | exports.expectNoHiddenParents = expectNoHiddenParents;
|
71 |
|
\ | No newline at end of file |