Skip to content

Commit 49ad766

Browse files
committed
fixed more tests
1 parent 47718c9 commit 49ad766

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/converters/includes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* Converts an array of strings into a comma-separated string prefixed with "in:".
2+
* Converts an array of strings into a comma-separated string prefixed with "includes:".
33
*
44
* @param {string[]} items - The array of strings to be joined.
5-
* @returns {string} The formatted string in the form "in:item1,item2,...".
5+
* @returns {string} The formatted string in the form "includes:item1,item2,...".
66
*/
77
export default (items: string[]): string => {
88
return `includes:${items.join(",")}`;

src/converters/notIncludes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* The field under validation must not be included in the given list of values.
33
*
44
* @example
5-
* import { notIn } from "robust-validator"
5+
* import { notIncludes } from "robust-validator"
66
*
77
* const definition = {
8-
* value: [notIn(["apple", "orange"])]
8+
* value: [notIncludes(["apple", "orange"])]
99
* };
1010
* @type {string}
11-
* @tutorial https://validator.axe-api.com/rules.html#not-in-foo-bar
11+
* @tutorial https://validator.axe-api.com/rules.html#not-includes-foo-bar
1212
*/
1313
export default (items: string[]): string => {
1414
return `not_includes:${items.join(",")}`;

src/rules/isNotIncludes.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import isNotIncludes from "./isNotIncludes";
33

44
describe("isNotIncludes() ", () => {
55
it("should return false for null or undefined values", () => {
6-
expect(isNotIncludes(null, "a,b,c")).toBe(false);
7-
expect(isNotIncludes(undefined, "a,b,c")).toBe(false);
6+
expect(isNotIncludes(null, "a,b,c")).toBe(true);
7+
expect(isNotIncludes(undefined, "a,b,c")).toBe(true);
88
});
99

1010
it("should return false if value is in the list", () => {

src/rules/isNotIncludes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import isIncludes from "./isIncludes";
22

3-
export default (value: unknown, ...args: unknown[]): boolean => {
3+
export default (
4+
value: string | number | null | undefined,
5+
...args: unknown[]
6+
): boolean => {
47
if (value === undefined || value === null) {
5-
return false;
8+
return true;
69
}
710

811
return !isIncludes(value, args);

0 commit comments

Comments
 (0)