Skip to content

Commit

Permalink
when type empty, should equal name
Browse files Browse the repository at this point in the history
  • Loading branch information
arvitaly committed Sep 12, 2016
1 parent 1df2705 commit 058a40a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ var fix = function () {
var fixtures = {};
return function (name, type) {
if (!fixtures[name] || type) {
var isEmptyType = false;
if (typeof (type) === "undefined") {
isEmptyType = true;
type = "string";
}
if (typeof (type) === "string" && fix[type]) {
if (type === "string") {
if (isEmptyType) {
fixtures[name] = name;
} else {
fixtures[name] = fix[type]();
Expand Down
2 changes: 1 addition & 1 deletion spec/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it("when type setted and exists, should call fixture-func", () => {
var res = f("test1", "int");
expect(res).toEqual(jasmine.any(Number));
})
it("when type is string, should be as name", () => {
it("when type is empty, should be as name", () => {
var f = fixtures();
var res = f("test1");
expect(res).toBe("test1");
Expand Down

0 comments on commit 058a40a

Please sign in to comment.