Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Jan 18, 2024
1 parent 39653d9 commit ae34000
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/utils/test/is.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
isErrorEvent,
isInstanceOf,
isNaN,
isPlainObject,
isPrimitive,
isThenable,
isVueViewModel,
Expand Down Expand Up @@ -144,3 +145,27 @@ describe('isVueViewModel()', () => {
expect(isVueViewModel({ foo: true })).toEqual(false);
});
});

describe('isPlainObject', () => {
class MyClass {
public foo: string = 'bar';
}

it.each([
[{}, true],
[true, false],
[false, false],
[undefined, false],
[null, false],
['', false],
[1, false],
[0, false],
[{ aha: 'yes' }, true],
[new Object({ aha: 'yes' }), true],
[new String('aa'), false],
[new MyClass(), true],
[{ ...new MyClass() }, true],
])('%s is %s', (value, expected) => {
expect(isPlainObject(value)).toBe(expected);
});
});

0 comments on commit ae34000

Please sign in to comment.