Skip to content

Commit

Permalink
feat(ch15): support factory functions with default params
Browse files Browse the repository at this point in the history
  • Loading branch information
poulzinho committed Feb 22, 2020
1 parent 2d776d5 commit a1f31e0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ch-15_factory-functions/15.1_factory-functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,19 @@ describe("Factory Functions", () => {
expect(aUser.avatar).equal("polo.png");
});

it("should support factory functions with default parameters", () => {
const createUser = ({
userName = "anon",
avatar = "anon.png"
} = {}) => ({
userName,
avatar,
});

const aUser = createUser();

expect(aUser.userName).equal("anon");
expect(aUser.avatar).equal("anon.png");
});

});

0 comments on commit a1f31e0

Please sign in to comment.