Skip to content

Commit d7414d0

Browse files
committed
test: update
1 parent 2a0448c commit d7414d0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/__tests__/random.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,48 @@ describe('randomInt', () => {
66
it('should return an integer value within the range', () => {
77
const min = 5;
88
const max = 8;
9-
const result = randomInt(min, max);
9+
const result = randomInt(min, max)._unsafeUnwrap();
1010
expect(result).toBeGreaterThanOrEqual(min);
1111
expect(result).toBeLessThan(8);
1212
expect(Number.isInteger(result)).toBe(true);
1313
});
14-
it('should throw if the min value is larger than the max', () => {
15-
expect(() => randomInt(10, 5)).toThrow();
14+
it('should return an error if the min value is larger than the max', () => {
15+
expect(randomInt(10, 5).isErr()).toBe(true);
1616
});
17-
it('should throw if the min value equals the max', () => {
18-
expect(() => randomInt(10, 10)).toThrow();
17+
it('should return an error if the min value equals the max', () => {
18+
expect(randomInt(10, 10).isErr()).toBe(true);
1919
});
2020
it('should handle negative values', () => {
2121
const min = -5;
2222
const max = -3;
23-
const result = randomInt(min, max);
23+
const result = randomInt(min, max)._unsafeUnwrap();
2424
expect(result).toBeGreaterThanOrEqual(min);
2525
expect(result).toBeLessThan(8);
2626
expect(Number.isInteger(result)).toBe(true);
27-
expect(() => randomInt(max, min)).toThrow();
27+
expect(randomInt(max, min).isErr()).toBe(true);
2828
});
2929
});
3030

3131
describe('randomDate', () => {
3232
it('should return a date within the range', () => {
3333
const start = new Date(2000, 0, 1);
3434
const end = new Date();
35-
const random = randomDate(start, end);
35+
const random = randomDate(start, end)._unsafeUnwrap();
3636
expect(random.getTime() >= start.getTime()).toBe(true);
3737
expect(random.getTime() <= end.getTime()).toBe(true);
3838
});
39-
it('should throw if the end is before the start', () => {
40-
expect(() => randomDate(new Date(), new Date(2000, 0, 1))).toThrow();
39+
it('should return an error if the end is before the start', () => {
40+
expect(randomDate(new Date(), new Date(2000, 0, 1)).isErr()).toBe(true);
4141
});
4242
});
4343

4444
describe('randomValue', () => {
45-
it('should throw if given an empty array', () => {
46-
expect(() => randomValue([])).toThrow();
45+
it('should return an error if given an empty array', () => {
46+
expect(randomValue([]).isErr()).toBe(true);
4747
});
4848
it('should return a value in the array', () => {
4949
const arr = [-10, -20, -30];
50-
expect(arr.includes(randomValue(arr)));
50+
expect(arr.includes(randomValue(arr)._unsafeUnwrap()));
5151
});
5252
it('should not mutate the array', () => {
5353
const arr = [-10, -20, -30];

0 commit comments

Comments
 (0)