expect-webdriverio 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -9
- package/jasmine.d.ts +0 -1
- package/jest.d.ts +1 -1
- package/lib/constants.js +4 -0
- package/lib/index.js +14 -6
- package/lib/jasmineUtils.js +7 -17
- package/lib/matchers/browser/toHaveTitle.js +12 -23
- package/lib/matchers/browser/toHaveTitleContaining.js +3 -11
- package/lib/matchers/browser/toHaveUrl.js +12 -23
- package/lib/matchers/browser/toHaveUrlContaining.js +3 -11
- package/lib/matchers/element/toBeClickable.js +10 -21
- package/lib/matchers/element/toBeDisabled.js +3 -14
- package/lib/matchers/element/toBeDisplayed.js +10 -21
- package/lib/matchers/element/toBeDisplayedInViewport.js +10 -21
- package/lib/matchers/element/toBeEnabled.js +3 -14
- package/lib/matchers/element/toBeExisting.js +14 -27
- package/lib/matchers/element/toBeFocused.js +3 -14
- package/lib/matchers/element/toBeSelected.js +6 -19
- package/lib/matchers/element/toHaveAttribute.js +35 -46
- package/lib/matchers/element/toHaveAttributeContaining.js +4 -12
- package/lib/matchers/element/toHaveChildren.js +27 -39
- package/lib/matchers/element/toHaveClass.js +47 -0
- package/lib/matchers/element/toHaveClassContaining.js +10 -0
- package/lib/matchers/element/toHaveElementProperty.js +25 -36
- package/lib/matchers/element/toHaveHref.js +4 -13
- package/lib/matchers/element/toHaveHrefContaining.js +4 -12
- package/lib/matchers/element/toHaveId.js +3 -12
- package/lib/matchers/element/toHaveStyle.js +17 -28
- package/lib/matchers/element/toHaveText.js +18 -29
- package/lib/matchers/element/toHaveTextContaining.js +3 -11
- package/lib/matchers/element/toHaveValue.js +3 -12
- package/lib/matchers/element/toHaveValueContaining.js +3 -11
- package/lib/matchers/elements/toBeElementsArrayOfSize.js +16 -26
- package/lib/matchers/mock/toBeRequested.js +3 -11
- package/lib/matchers/mock/toBeRequestedTimes.js +17 -32
- package/lib/matchers/mock/toBeRequestedWith.js +30 -39
- package/lib/matchers.js +62 -35
- package/lib/types.js +1 -0
- package/lib/util/elementsUtil.js +2 -7
- package/lib/util/executeCommand.js +3 -7
- package/lib/util/formatMessage.js +17 -26
- package/lib/util/refetchElements.js +2 -8
- package/lib/utils.js +41 -49
- package/package.json +59 -44
- package/types/expect-webdriverio.d.ts +23 -22
- package/types/jest-global.d.ts +1 -1
- package/types/standalone.d.ts +2 -2
- package/lib/addMatchers.js +0 -48
- package/lib/matchers/element/toHaveElementClass.js +0 -60
- package/lib/matchers/element/toHaveElementClassContaining.js +0 -20
- package/lib/matchers/mock/toBeRequestedWithResponse.js +0 -13
- package/lib/options.js +0 -33
- package/lib/util/expectAdapter.js +0 -41
- package/types/standalone-global.d.ts +0 -9
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
-
function toHaveAttributeContainingFn(el, attribute, value, options = {}) {
|
|
7
|
-
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, attribute, value, {
|
|
1
|
+
import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
|
|
2
|
+
export function toHaveAttributeContaining(el, attribute, value, options = {}) {
|
|
3
|
+
return toHaveAttributeAndValueFn.call(this, el, attribute, value, {
|
|
8
4
|
...options,
|
|
9
5
|
containing: true
|
|
10
6
|
});
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
return expectAdapter_1.runExpect.call(this, toHaveAttributeContainingFn, args);
|
|
14
|
-
}
|
|
15
|
-
exports.toHaveAttributeContaining = toHaveAttributeContaining;
|
|
16
|
-
exports.toHaveAttrContaining = toHaveAttributeContaining;
|
|
8
|
+
export const toHaveAttrContaining = toHaveAttributeContaining;
|
|
@@ -1,51 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHaveChildren = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
1
|
+
import { waitUntil, enhanceError, compareNumbers, numberError, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
|
|
6
2
|
async function condition(el, options) {
|
|
7
3
|
const children = await el.$$('./*');
|
|
8
|
-
if (
|
|
4
|
+
if (typeof options.lte !== 'number' &&
|
|
5
|
+
typeof options.gte !== 'number' &&
|
|
6
|
+
typeof options.eq !== 'number') {
|
|
9
7
|
return {
|
|
10
8
|
result: children.length > 0,
|
|
11
|
-
value: children
|
|
9
|
+
value: children?.length
|
|
12
10
|
};
|
|
13
11
|
}
|
|
14
12
|
return {
|
|
15
|
-
result:
|
|
16
|
-
value: children
|
|
13
|
+
result: compareNumbers(children?.length, options),
|
|
14
|
+
value: children?.length
|
|
17
15
|
};
|
|
18
16
|
}
|
|
19
|
-
function
|
|
17
|
+
export async function toHaveChildren(received, expected, options = {}) {
|
|
20
18
|
const isNot = this.isNot;
|
|
21
19
|
const { expectation = 'children', verb = 'have' } = this;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const message = utils_1.enhanceError(el, expected, children, this, verb, expectation, '', numberOptions);
|
|
42
|
-
return {
|
|
43
|
-
pass,
|
|
44
|
-
message: () => message
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function toHaveChildren(...args) {
|
|
49
|
-
return expectAdapter_1.runExpect.call(this, toHaveChildrenFn, args);
|
|
20
|
+
const numberOptions = typeof expected === 'number'
|
|
21
|
+
? { eq: expected }
|
|
22
|
+
: expected || {};
|
|
23
|
+
let el = await received;
|
|
24
|
+
let children;
|
|
25
|
+
const pass = await waitUntil(async () => {
|
|
26
|
+
const result = await executeCommand.call(this, el, condition, numberOptions, [numberOptions]);
|
|
27
|
+
el = result.el;
|
|
28
|
+
children = result.values;
|
|
29
|
+
return result.success;
|
|
30
|
+
}, isNot, { ...numberOptions, ...options });
|
|
31
|
+
updateElementsArray(pass, received, el);
|
|
32
|
+
const error = numberError(numberOptions);
|
|
33
|
+
const expectedArray = wrapExpectedWithArray(el, children, error);
|
|
34
|
+
const message = enhanceError(el, expectedArray, children, this, verb, expectation, '', numberOptions);
|
|
35
|
+
return {
|
|
36
|
+
pass,
|
|
37
|
+
message: () => message
|
|
38
|
+
};
|
|
50
39
|
}
|
|
51
|
-
exports.toHaveChildren = toHaveChildren;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
|
|
2
|
+
async function condition(el, attribute, value, options) {
|
|
3
|
+
const { ignoreCase = false, trim = false, containing = false } = options;
|
|
4
|
+
let attr = await el.getAttribute(attribute);
|
|
5
|
+
if (typeof attr !== 'string') {
|
|
6
|
+
return { result: false };
|
|
7
|
+
}
|
|
8
|
+
if (trim) {
|
|
9
|
+
attr = attr.trim();
|
|
10
|
+
}
|
|
11
|
+
if (ignoreCase) {
|
|
12
|
+
attr = attr.toLowerCase();
|
|
13
|
+
if (!(value instanceof RegExp)) {
|
|
14
|
+
value = value.toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const classes = attr.split(' ');
|
|
18
|
+
const valueInClasses = classes.some((t) => {
|
|
19
|
+
return value instanceof RegExp ? !!t.match(value) : containing ? t.includes(value) : t === value;
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
value: attr,
|
|
23
|
+
result: valueInClasses
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function toHaveElementClass(...args) {
|
|
27
|
+
return toHaveClass.call(this || {}, ...args);
|
|
28
|
+
}
|
|
29
|
+
export async function toHaveClass(received, className, options = {}) {
|
|
30
|
+
const isNot = this.isNot;
|
|
31
|
+
const { expectation = 'class', verb = 'have' } = this;
|
|
32
|
+
const attribute = 'class';
|
|
33
|
+
let el = await received;
|
|
34
|
+
let attr;
|
|
35
|
+
const pass = await waitUntil(async () => {
|
|
36
|
+
const result = await executeCommand.call(this, el, condition, options, [attribute, className, options]);
|
|
37
|
+
el = result.el;
|
|
38
|
+
attr = result.values;
|
|
39
|
+
return result.success;
|
|
40
|
+
}, isNot, options);
|
|
41
|
+
updateElementsArray(pass, received, el);
|
|
42
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, attr, className), attr, this, verb, expectation, '', options);
|
|
43
|
+
return {
|
|
44
|
+
pass,
|
|
45
|
+
message: () => message
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
|
|
2
|
+
export function toHaveElementClassContaining(...args) {
|
|
3
|
+
return toHaveClassContaining.call(this, ...args);
|
|
4
|
+
}
|
|
5
|
+
export function toHaveClassContaining(el, className, options = {}) {
|
|
6
|
+
return toHaveAttributeAndValueFn.call(this, el, 'class', className, {
|
|
7
|
+
...options,
|
|
8
|
+
containing: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHaveElementProperty = exports.toHaveElementPropertyFn = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
1
|
+
import { waitUntil, enhanceError, compareText, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
|
|
6
2
|
async function condition(el, property, value, options = {}) {
|
|
7
3
|
const { asString = false } = options;
|
|
8
4
|
let prop = await el.getProperty(property);
|
|
@@ -12,41 +8,34 @@ async function condition(el, property, value, options = {}) {
|
|
|
12
8
|
if (value === null) {
|
|
13
9
|
return { result: true, value: prop };
|
|
14
10
|
}
|
|
15
|
-
if (typeof value !== 'string' || (typeof prop !== 'string' && !asString)) {
|
|
11
|
+
if (!(value instanceof RegExp) && (typeof value !== 'string' || (typeof prop !== 'string' && !asString))) {
|
|
16
12
|
return { result: prop === value, value: prop };
|
|
17
13
|
}
|
|
18
14
|
prop = prop.toString();
|
|
19
|
-
return
|
|
15
|
+
return compareText(prop, value, options);
|
|
20
16
|
}
|
|
21
|
-
function
|
|
17
|
+
export async function toHaveElementProperty(received, property, value, options = {}) {
|
|
22
18
|
const isNot = this.isNot;
|
|
23
19
|
const { expectation = 'property', verb = 'have' } = this;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
exports.toHaveElementPropertyFn = toHaveElementPropertyFn;
|
|
49
|
-
function toHaveElementProperty(...args) {
|
|
50
|
-
return expectAdapter_1.runExpect.call(this, toHaveElementPropertyFn, args);
|
|
20
|
+
let el = await received;
|
|
21
|
+
let prop;
|
|
22
|
+
const pass = await waitUntil(async () => {
|
|
23
|
+
const result = await executeCommand.call(this, el, condition, options, [property, value]);
|
|
24
|
+
el = result.el;
|
|
25
|
+
prop = result.values;
|
|
26
|
+
return result.success;
|
|
27
|
+
}, isNot, options);
|
|
28
|
+
updateElementsArray(pass, received, el);
|
|
29
|
+
let message;
|
|
30
|
+
if (value === undefined) {
|
|
31
|
+
message = enhanceError(el, !isNot, pass, this, verb, expectation, property, options);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const expected = wrapExpectedWithArray(el, prop, value);
|
|
35
|
+
message = enhanceError(el, expected, prop, this, verb, expectation, property, options);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
pass,
|
|
39
|
+
message: () => message,
|
|
40
|
+
};
|
|
51
41
|
}
|
|
52
|
-
exports.toHaveElementProperty = toHaveElementProperty;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
-
function toHaveHrefFn(el, href, options = {}) {
|
|
7
|
-
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, 'href', href, options);
|
|
1
|
+
import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
|
|
2
|
+
export function toHaveHref(el, href, options = {}) {
|
|
3
|
+
return toHaveAttributeAndValueFn.call(this, el, 'href', href, options);
|
|
8
4
|
}
|
|
9
|
-
|
|
10
|
-
function toHaveHref(...args) {
|
|
11
|
-
return expectAdapter_1.runExpect.call(this, toHaveHrefFn, args);
|
|
12
|
-
}
|
|
13
|
-
exports.toHaveHref = toHaveHref;
|
|
14
|
-
exports.toHaveLink = toHaveHref;
|
|
5
|
+
export const toHaveLink = toHaveHref;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveHref_1 = require("./toHaveHref");
|
|
6
|
-
function toHaveHrefContainingFn(el, href, options = {}) {
|
|
7
|
-
return toHaveHref_1.toHaveHrefFn.call(this, el, href, {
|
|
1
|
+
import { toHaveHref } from './toHaveHref.js';
|
|
2
|
+
export function toHaveHrefContaining(el, href, options = {}) {
|
|
3
|
+
return toHaveHref.call(this, el, href, {
|
|
8
4
|
...options,
|
|
9
5
|
containing: true
|
|
10
6
|
});
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
return expectAdapter_1.runExpect.call(this, toHaveHrefContainingFn, args);
|
|
14
|
-
}
|
|
15
|
-
exports.toHaveHrefContaining = toHaveHrefContaining;
|
|
16
|
-
exports.toHaveLinkContaining = toHaveHrefContaining;
|
|
8
|
+
export const toHaveLinkContaining = toHaveHrefContaining;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveAttribute_1 = require("./toHaveAttribute");
|
|
6
|
-
function toHaveIdFn(el, id, options = {}) {
|
|
7
|
-
return toHaveAttribute_1.toHaveAttributeAndValueFn.call(this, el, 'id', id, options);
|
|
1
|
+
import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
|
|
2
|
+
export function toHaveId(el, id, options = {}) {
|
|
3
|
+
return toHaveAttributeAndValueFn.call(this, el, 'id', id, options);
|
|
8
4
|
}
|
|
9
|
-
exports.toHaveIdFn = toHaveIdFn;
|
|
10
|
-
function toHaveId(...args) {
|
|
11
|
-
return expectAdapter_1.runExpect.call(this, toHaveIdFn, args);
|
|
12
|
-
}
|
|
13
|
-
exports.toHaveId = toHaveId;
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHaveStyle = exports.toHaveStyleFn = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
1
|
+
import { waitUntil, enhanceError, compareStyle, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
|
|
6
2
|
async function condition(el, style, options) {
|
|
7
|
-
return
|
|
3
|
+
return compareStyle(el, style, options);
|
|
8
4
|
}
|
|
9
|
-
function
|
|
5
|
+
export async function toHaveStyle(received, style, options = {}) {
|
|
10
6
|
const isNot = this.isNot;
|
|
11
7
|
const { expectation = 'style', verb = 'have' } = this;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
});
|
|
8
|
+
let el = await received;
|
|
9
|
+
let actualStyle;
|
|
10
|
+
const pass = await waitUntil(async () => {
|
|
11
|
+
const result = await executeCommand.call(this, el, condition, options, [style, options]);
|
|
12
|
+
el = result.el;
|
|
13
|
+
actualStyle = result.values;
|
|
14
|
+
return result.success;
|
|
15
|
+
}, isNot, options);
|
|
16
|
+
updateElementsArray(pass, received, el);
|
|
17
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualStyle, style), actualStyle, this, verb, expectation, '', options);
|
|
18
|
+
return {
|
|
19
|
+
pass,
|
|
20
|
+
message: () => message
|
|
21
|
+
};
|
|
28
22
|
}
|
|
29
|
-
exports.toHaveStyleFn = toHaveStyleFn;
|
|
30
|
-
function toHaveStyle(...args) {
|
|
31
|
-
return expectAdapter_1.runExpect.call(this, toHaveStyleFn, args);
|
|
32
|
-
}
|
|
33
|
-
exports.toHaveStyle = toHaveStyle;
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHaveText = exports.toHaveTextFn = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
1
|
+
import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
|
|
6
2
|
async function condition(el, text, options) {
|
|
7
3
|
const actualText = await el.getText();
|
|
8
4
|
if (Array.isArray(text)) {
|
|
9
|
-
return
|
|
5
|
+
return compareTextWithArray(actualText, text, options);
|
|
10
6
|
}
|
|
11
|
-
return
|
|
7
|
+
return compareText(actualText, text, options);
|
|
12
8
|
}
|
|
13
|
-
function
|
|
9
|
+
export async function toHaveText(received, text, options = {}) {
|
|
14
10
|
const isNot = this.isNot;
|
|
15
11
|
const { expectation = 'text', verb = 'have' } = this;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
});
|
|
12
|
+
let el = await received;
|
|
13
|
+
let actualText;
|
|
14
|
+
const pass = await waitUntil(async () => {
|
|
15
|
+
const result = await executeCommand.call(this, el, condition, options, [text, options]);
|
|
16
|
+
el = result.el;
|
|
17
|
+
actualText = result.values;
|
|
18
|
+
return result.success;
|
|
19
|
+
}, isNot, options);
|
|
20
|
+
updateElementsArray(pass, received, el);
|
|
21
|
+
const message = enhanceError(el, wrapExpectedWithArray(el, actualText, text), actualText, this, verb, expectation, '', options);
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => message
|
|
25
|
+
};
|
|
32
26
|
}
|
|
33
|
-
exports.toHaveTextFn = toHaveTextFn;
|
|
34
|
-
function toHaveText(...args) {
|
|
35
|
-
return expectAdapter_1.runExpect.call(this, toHaveTextFn, args);
|
|
36
|
-
}
|
|
37
|
-
exports.toHaveText = toHaveText;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveText_1 = require("./toHaveText");
|
|
6
|
-
function toHaveTextContainingFn(el, text, options = {}) {
|
|
7
|
-
return toHaveText_1.toHaveTextFn.call(this, el, text, {
|
|
1
|
+
import { toHaveText } from './toHaveText.js';
|
|
2
|
+
export function toHaveTextContaining(el, text, options = {}) {
|
|
3
|
+
return toHaveText.call(this, el, text, {
|
|
8
4
|
...options,
|
|
9
5
|
containing: true
|
|
10
6
|
});
|
|
11
7
|
}
|
|
12
|
-
function toHaveTextContaining(...args) {
|
|
13
|
-
return expectAdapter_1.runExpect.call(this, toHaveTextContainingFn, args);
|
|
14
|
-
}
|
|
15
|
-
exports.toHaveTextContaining = toHaveTextContaining;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveElementProperty_1 = require("./toHaveElementProperty");
|
|
6
|
-
function toHaveValueFn(el, value, options = {}) {
|
|
7
|
-
return toHaveElementProperty_1.toHaveElementPropertyFn.call(this, el, 'value', value, options);
|
|
1
|
+
import { toHaveElementProperty } from './toHaveElementProperty.js';
|
|
2
|
+
export function toHaveValue(el, value, options = {}) {
|
|
3
|
+
return toHaveElementProperty.call(this, el, 'value', value, options);
|
|
8
4
|
}
|
|
9
|
-
exports.toHaveValueFn = toHaveValueFn;
|
|
10
|
-
function toHaveValue(...args) {
|
|
11
|
-
return expectAdapter_1.runExpect.call(this, toHaveValueFn, args);
|
|
12
|
-
}
|
|
13
|
-
exports.toHaveValue = toHaveValue;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
5
|
-
const toHaveValue_1 = require("./toHaveValue");
|
|
6
|
-
function toHaveValueContainingFn(el, value, options = {}) {
|
|
7
|
-
return toHaveValue_1.toHaveValueFn.call(this, el, value, {
|
|
1
|
+
import { toHaveValue } from './toHaveValue.js';
|
|
2
|
+
export function toHaveValueContaining(el, value, options = {}) {
|
|
3
|
+
return toHaveValue.call(this, el, value, {
|
|
8
4
|
...options,
|
|
9
5
|
containing: true
|
|
10
6
|
});
|
|
11
7
|
}
|
|
12
|
-
function toHaveValueContaining(...args) {
|
|
13
|
-
return expectAdapter_1.runExpect.call(this, toHaveValueContainingFn, args);
|
|
14
|
-
}
|
|
15
|
-
exports.toHaveValueContaining = toHaveValueContaining;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const refetchElements_1 = require("../../util/refetchElements");
|
|
6
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
7
|
-
function toBeElementsArrayOfSizeFn(received, expected, options = {}) {
|
|
1
|
+
import { waitUntil, enhanceError, compareNumbers, numberError, updateElementsArray } from '../../utils.js';
|
|
2
|
+
import { refetchElements } from '../../util/refetchElements.js';
|
|
3
|
+
export async function toBeElementsArrayOfSize(received, expected, options = {}) {
|
|
8
4
|
const isNot = this.isNot;
|
|
9
5
|
const { expectation = 'elements array of size', verb = 'be' } = this;
|
|
10
6
|
let numberOptions;
|
|
@@ -17,23 +13,17 @@ function toBeElementsArrayOfSizeFn(received, expected, options = {}) {
|
|
|
17
13
|
else {
|
|
18
14
|
numberOptions = expected;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
});
|
|
16
|
+
let elements = await received;
|
|
17
|
+
const arrLength = elements.length;
|
|
18
|
+
const pass = await waitUntil(async () => {
|
|
19
|
+
elements = await refetchElements(elements, numberOptions.wait, true);
|
|
20
|
+
return compareNumbers(elements.length, numberOptions);
|
|
21
|
+
}, isNot, { ...numberOptions, ...options });
|
|
22
|
+
updateElementsArray(pass, received, elements, true);
|
|
23
|
+
const error = numberError(numberOptions);
|
|
24
|
+
const message = enhanceError(elements, error, arrLength, this, verb, expectation, '', numberOptions);
|
|
25
|
+
return {
|
|
26
|
+
pass,
|
|
27
|
+
message: () => message
|
|
28
|
+
};
|
|
35
29
|
}
|
|
36
|
-
function toBeElementsArrayOfSize(...args) {
|
|
37
|
-
return expectAdapter_1.runExpect.call(this, toBeElementsArrayOfSizeFn, args);
|
|
38
|
-
}
|
|
39
|
-
exports.toBeElementsArrayOfSize = toBeElementsArrayOfSize;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const toBeRequestedTimes_1 = require("./toBeRequestedTimes");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
-
function toBeRequestedFn(received, options = {}) {
|
|
7
|
-
return toBeRequestedTimes_1.toBeRequestedTimes.call({ ...(this || {}), expectation: 'called' }, received, { ...options, gte: 1 });
|
|
1
|
+
import { toBeRequestedTimes } from './toBeRequestedTimes.js';
|
|
2
|
+
export function toBeRequested(received, options = {}) {
|
|
3
|
+
return toBeRequestedTimes.call({ ...(this || {}), expectation: 'called' }, received, { ...options, gte: 1 });
|
|
8
4
|
}
|
|
9
|
-
function toBeRequested(...args) {
|
|
10
|
-
return expectAdapter_1.runExpect.call(this, toBeRequestedFn, args);
|
|
11
|
-
}
|
|
12
|
-
exports.toBeRequested = toBeRequested;
|
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const expectAdapter_1 = require("../../util/expectAdapter");
|
|
6
|
-
const formatMessage_1 = require("../../util/formatMessage");
|
|
7
|
-
function toBeRequestedTimesFn(received, expected = {}, options = {}) {
|
|
1
|
+
import { waitUntil, enhanceError, compareNumbers } from '../../utils.js';
|
|
2
|
+
import { numberError } from '../../util/formatMessage.js';
|
|
3
|
+
export async function toBeRequestedTimes(received, expected = {}, options = {}) {
|
|
8
4
|
const isNot = this.isNot || false;
|
|
9
5
|
const { expectation = `called${typeof expected === 'number' ? ' ' + expected : ''} time${expected !== 1 ? 's' : ''}`, verb = 'be' } = this;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const message = utils_1.enhanceError('mock', error, actual, this, verb, expectation, '', numberOptions);
|
|
25
|
-
return {
|
|
26
|
-
pass,
|
|
27
|
-
message: () => message
|
|
28
|
-
};
|
|
29
|
-
});
|
|
6
|
+
const numberOptions = typeof expected === 'number'
|
|
7
|
+
? { eq: expected }
|
|
8
|
+
: expected || {};
|
|
9
|
+
let actual;
|
|
10
|
+
const pass = await waitUntil(async () => {
|
|
11
|
+
actual = received.calls.length;
|
|
12
|
+
return compareNumbers(actual, numberOptions);
|
|
13
|
+
}, isNot, { ...numberOptions, ...options });
|
|
14
|
+
const error = numberError(numberOptions);
|
|
15
|
+
const message = enhanceError('mock', error, actual, this, verb, expectation, '', numberOptions);
|
|
16
|
+
return {
|
|
17
|
+
pass,
|
|
18
|
+
message: () => message
|
|
19
|
+
};
|
|
30
20
|
}
|
|
31
|
-
exports.toBeRequestedTimesFn = toBeRequestedTimesFn;
|
|
32
|
-
function toBeRequestedTimes(...args) {
|
|
33
|
-
return expectAdapter_1.runExpect.call(this, toBeRequestedTimesFn, args);
|
|
34
|
-
}
|
|
35
|
-
exports.toBeRequestedTimes = toBeRequestedTimes;
|