Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export * from './slug/index.ts';
export * from './someItem/index.ts';
export * from './sortItems/index.ts';
export * from './startsWith/index.ts';
export * from './stringbool/index.ts';
export * from './stringifyJson/index.ts';
export * from './title/index.ts';
export * from './toLowerCase/index.ts';
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/stringbool/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './stringbool.ts';
49 changes: 49 additions & 0 deletions library/src/actions/stringbool/stringbool.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { describe, expectTypeOf, test } from 'vitest';
import type { InferInput, InferIssue, InferOutput } from '../../types/index.ts';
import {
stringbool,
type StringboolAction,
type StringboolIssue,
type StringboolOptions,
} from './stringbool.ts';

describe('stringbool', () => {
describe('should return action object', () => {
test('with undefined options', () => {
type Action = StringboolAction<'foo', StringboolOptions>;

expectTypeOf(stringbool<'foo'>()).toEqualTypeOf<Action>();
expectTypeOf(stringbool<'foo'>(undefined)).toEqualTypeOf<Action>();
});

test('with custom options', () => {
const options: StringboolOptions = {
truthy: ['yep'],
falsy: ['nope'],
case: 'sensitive',
};

expectTypeOf(stringbool<'foo'>(options)).toEqualTypeOf<
StringboolAction<'foo', StringboolOptions>
>();
});
});

describe('should infer correct types', () => {
type Action = StringboolAction<'foo', StringboolOptions>;

test('of input', () => {
expectTypeOf<InferInput<Action>>().toEqualTypeOf<'foo'>();
});

test('of output', () => {
expectTypeOf<InferOutput<Action>>().toEqualTypeOf<boolean>();
});

test('of issue', () => {
expectTypeOf<InferIssue<Action>>().toEqualTypeOf<
StringboolIssue<'foo'>
>();
});
});
});
Loading