Skip to content

Commit

Permalink
fix(formats): Making sure to default the defaults, adding test for me…
Browse files Browse the repository at this point in the history
…rge deep
  • Loading branch information
Joshua Godi committed Feb 21, 2017
1 parent 5e2cd5c commit 124e3e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export interface IFormatDefaults {
*/
export class Formats {
// Format formatDefaults
private defaults: IFormatDefaults;
private defaults: IFormatDefaults = {
number: {},
currency: {},
date: {}
};
// Current locale
private locale: string;
// Override currency to blanket change the currency behavior
Expand Down
7 changes: 7 additions & 0 deletions src/lib/object-assign-deep.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ test('mergeDeep should merge objects with functions', t => {
t.true(isFunction(result.a));
t.true(isFunction(result.b));
});

test('mergeDeep should handle undefined', t => {
const a = { a: 1 };
const b = { b: { c: { d: 1 } } };
const result = { a: 1, b: { c: { d: 1 } } };
t.deepEqual(mergeDeep(a, b, undefined), result);
});

0 comments on commit 124e3e9

Please sign in to comment.