-
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
4 changed files
with
3,886 additions
and
4,574 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
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 |
---|---|---|
|
@@ -12,8 +12,9 @@ import { | |
isNumber, | ||
isEffectiveNumber, | ||
isPromise, | ||
isEffectiveArray | ||
} from '../../lib/validate' | ||
isValidArray, | ||
isValidDate | ||
} from '../../lib' | ||
|
||
describe('isArrayEquals', () => { | ||
it('should return true if two arrays are equal', () => { | ||
|
@@ -221,17 +222,56 @@ describe('isPromise', () => { | |
}) | ||
}) | ||
|
||
describe('isEffectiveArray', () => { | ||
describe('isValidArray', () => { | ||
test('should return true for a non-empty array', () => { | ||
expect(isEffectiveArray([1, 2, 3])).toBe(true) | ||
expect(isValidArray([1, 2, 3])).toBe(true) | ||
}) | ||
|
||
test('should return false for an empty array', () => { | ||
expect(isEffectiveArray([])).toBe(false) | ||
expect(isValidArray([])).toBe(false) | ||
}) | ||
|
||
test('should return false for a non-array', () => { | ||
// @ts-expect-error: ignore | ||
expect(isEffectiveArray(123)).toBe(false) | ||
test('should return false for a non-array value', () => { | ||
// @ts-ignore | ||
Check failure on line 235 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 252 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 257 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 262 in __test__/lib/validate.test.ts GitHub Actions / lint
|
||
expect(isValidArray({})).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isValidDate function', () => { | ||
it('should return true for a valid date', () => { | ||
const validDate = new Date(); | ||
expect(isValidDate(validDate)).toBe(true); | ||
}); | ||
|
||
it('should return false for an invalid date', () => { | ||
const invalidDate = new Date('invalid'); | ||
expect(isValidDate(invalidDate)).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
Oops, something went wrong.