-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ import { | |
isFalsy, | ||
isNumber, | ||
isEffectiveNumber, | ||
isPromise | ||
isPromise, | ||
isValidArray | ||
} from '../../lib/validate' | ||
|
||
describe('isArrayEquals', () => { | ||
|
@@ -219,3 +220,45 @@ describe('isPromise', () => { | |
expect(isPromise(null)).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isValidArray', () => { | ||
test('should return true for a non-empty array', () => { | ||
expect(isValidArray([1, 2, 3])).toBe(true); | ||
}); | ||
|
||
test('should return false for an empty array', () => { | ||
expect(isValidArray([])).toBe(false); | ||
}); | ||
|
||
test('should return false for a non-array value', () => { | ||
// @ts-ignore | ||
Check failure on line 234 in __test__/lib/validate.test.ts GitHub Actions / lint
|
||
expect(isValidArray(123)).toBe(false); | ||
}); | ||
|
||
test('should return false for an array with length 0', () => { | ||
expect(isValidArray([])).toBe(false); | ||
}); | ||
|
||
test('should return true for an array with length greater than 0', () => { | ||
expect(isValidArray([1])).toBe(true); | ||
}); | ||
|
||
test('should return true for a complex array', () => { | ||
expect(isValidArray([{ a: 1 }, { b: 2 }])).toBe(true); | ||
}); | ||
|
||
test('should return false for undefined', () => { | ||
// @ts-ignore | ||
Check failure on line 251 in __test__/lib/validate.test.ts GitHub Actions / lint
|
||
expect(isValidArray(undefined)).toBe(false); | ||
}); | ||
|
||
test('should return false for null', () => { | ||
// @ts-ignore | ||
Check failure on line 256 in __test__/lib/validate.test.ts GitHub Actions / lint
|
||
expect(isValidArray(null)).toBe(false); | ||
}); | ||
|
||
test('should return false for an object', () => { | ||
// @ts-ignore | ||
Check failure on line 261 in __test__/lib/validate.test.ts GitHub Actions / lint
|
||
expect(isValidArray({})).toBe(false); | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters