Skip to content

Commit

Permalink
test(core): add tests for OptionalCompareKeys when TResult has option…
Browse files Browse the repository at this point in the history
…al keys (#58)
  • Loading branch information
L2HYUNN authored Sep 18, 2024
1 parent 0af3a1a commit 6f10dff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/core/test/typeUtil.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ describe('typeUtil test', () => {
});
});

describe('When TBase has no key and TResult has compare optional key', () => {
test('Should return the keys that are optional when converting from TBase to TResult', () => {
type Result = OptionalCompareKeys<{ a: string }, { a: string; b?: string }>;
expectTypeOf<Result>().toEqualTypeOf<'a' | 'b'>();
});
});

describe('When TBase has no keys', () => {
test('Should return the never', () => {
type Result = OptionalCompareKeys<{}, { a: string; b: string }>;
Expand Down Expand Up @@ -98,6 +105,13 @@ describe('typeUtil test', () => {
});
});

describe('When TBase has no key and TResult has compare optional key', () => {
test('Should return the new object that uses TResult values for optional keys, and TBase values for optional keys', () => {
type Result = CompareMergeContext<{ a: string }, { a: string; b?: string }>;
expectTypeOf<Result>().toEqualTypeOf<{ a?: string; b?: string }>();
});
});

describe('When TBase has no keys', () => {
test('Should return the TResult type', () => {
type Result = CompareMergeContext<{}, { a: string; b: string }>;
Expand Down

0 comments on commit 6f10dff

Please sign in to comment.