Skip to content

Commit ee99d12

Browse files
committed
Tests for isDict() and isArray()
1 parent 941c6bc commit ee99d12

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

projects/ngx-translate/src/lib/utils.spec.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {equals, getValue, mergeDeep} from "./util";
1+
import {equals, getValue, isArray, isDict, mergeDeep} from "./util";
22

33

44
describe("Utils", () =>
@@ -244,5 +244,34 @@ describe("Utils", () =>
244244

245245
});
246246

247+
describe('isDict()', () =>
248+
{
249+
it('should accept objects as dictionaries', () =>
250+
{
251+
expect(isDict({a: "b"})).toEqual(true);
252+
expect(isDict({})).toEqual(true);
253+
254+
expect(isDict(null)).toEqual(false);
255+
expect(isDict([])).toEqual(false);
256+
expect(isDict(123)).toEqual(false);
257+
expect(isDict("asd")).toEqual(false);
258+
}) ;
259+
});
260+
261+
describe('isArray()', () =>
262+
{
263+
it('should accept objects as dictionaries', () =>
264+
{
265+
expect(isArray([1,2,3])).toEqual(true);
266+
expect(isArray(["a","b","c"])).toEqual(true);
267+
expect(isArray([])).toEqual(true);
268+
269+
expect(isArray(null)).toEqual(false);
270+
expect(isArray({})).toEqual(false);
271+
expect(isArray({a:123})).toEqual(false);
272+
expect(isArray(123)).toEqual(false);
273+
expect(isArray("asd")).toEqual(false);
274+
}) ;
275+
});
247276

248277
});

0 commit comments

Comments
 (0)