Skip to content

Commit

Permalink
Tests for isDict() and isArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeAndWeb committed Dec 18, 2024
1 parent 941c6bc commit ee99d12
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion projects/ngx-translate/src/lib/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {equals, getValue, mergeDeep} from "./util";
import {equals, getValue, isArray, isDict, mergeDeep} from "./util";


describe("Utils", () =>
Expand Down Expand Up @@ -244,5 +244,34 @@ describe("Utils", () =>

});

describe('isDict()', () =>
{
it('should accept objects as dictionaries', () =>
{
expect(isDict({a: "b"})).toEqual(true);
expect(isDict({})).toEqual(true);

expect(isDict(null)).toEqual(false);
expect(isDict([])).toEqual(false);
expect(isDict(123)).toEqual(false);
expect(isDict("asd")).toEqual(false);
}) ;
});

describe('isArray()', () =>
{
it('should accept objects as dictionaries', () =>
{
expect(isArray([1,2,3])).toEqual(true);
expect(isArray(["a","b","c"])).toEqual(true);
expect(isArray([])).toEqual(true);

expect(isArray(null)).toEqual(false);
expect(isArray({})).toEqual(false);
expect(isArray({a:123})).toEqual(false);
expect(isArray(123)).toEqual(false);
expect(isArray("asd")).toEqual(false);
}) ;
});

});

0 comments on commit ee99d12

Please sign in to comment.