Skip to content

Commit

Permalink
Migrate fastMerge
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Apr 26, 2024
1 parent 357887d commit 09459d9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/unit/fastMergeTest.js → tests/unit/fastMergeTest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type {DeepRecord} from '../../lib/types';
import utils from '../../lib/utils';

const testObject = {
type DeepObject = DeepRecord<string, unknown> | unknown[];

const testObject: DeepObject = {
a: 'a',
b: {
c: 'c',
Expand All @@ -12,7 +15,7 @@ const testObject = {
},
};

const testObjectWithNullishValues = {
const testObjectWithNullishValues: DeepObject = {
a: undefined,
b: {
c: {
Expand All @@ -24,7 +27,7 @@ const testObjectWithNullishValues = {
},
};

const testObjectWithNullValuesRemoved = {
const testObjectWithNullValuesRemoved: DeepObject = {
b: {
c: {
h: 'h',
Expand Down Expand Up @@ -82,13 +85,15 @@ describe('fastMerge', () => {
});

it('should replace an object with an array', () => {
const result = utils.fastMerge(testObject, [1, 2, 3]);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result = utils.fastMerge(testObject, [1, 2, 3] as any);

expect(result).toEqual([1, 2, 3]);
});

it('should replace an array with an object', () => {
const result = utils.fastMerge([1, 2, 3], testObject);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result = utils.fastMerge([1, 2, 3] as any, testObject);

expect(result).toEqual(testObject);
});
Expand Down

0 comments on commit 09459d9

Please sign in to comment.