-
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
54 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect, test } from 'vitest'; | ||
import boundary from '../../src/helpers/boundary'; | ||
import { Failure } from '../../src/utils'; | ||
|
||
test('boundary - should return a Failure object when the inner function throws an error', async () => { | ||
function innerFunction() { | ||
throw new Error('Test error'); | ||
} | ||
|
||
const wrappedFunction = boundary(innerFunction); | ||
|
||
const result = await wrappedFunction(); | ||
|
||
expect(result).toStrictEqual(new Failure('Test error')); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { stdout } from 'node:process'; | ||
import { expect, test } from 'vitest'; | ||
import getColumns from '../../src/utils/get-columns'; | ||
|
||
test('getColumns - should return the number of columns', () => { | ||
stdout.columns = 80; | ||
const result = getColumns(); | ||
expect(result).toBe(80); | ||
}); | ||
|
||
test('getColumns - should return 0 if stdout.columns is undefined', () => { | ||
stdout.columns = undefined; | ||
const result = getColumns(); | ||
expect(result).toBe(0); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect, test } from 'vitest'; | ||
import isError from '../../src/utils/is-error'; | ||
|
||
test('isError - should return true for an Error object', () => { | ||
const error = new Error('Test error'); | ||
const result = isError(error); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test('isError - should return false for other types of values', () => { | ||
expect(isError('')).toBe(false); | ||
expect(isError(123)).toBe(false); | ||
expect(isError({})).toBe(false); | ||
expect(isError([])).toBe(false); | ||
expect(isError(null)).toBe(false); | ||
expect(isError(undefined)).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