diff --git a/index.js b/index.js index db6f729..05a1656 100644 --- a/index.js +++ b/index.js @@ -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](); diff --git a/spec/index-spec.js b/spec/index-spec.js index 186b0c1..62a97ee 100644 --- a/spec/index-spec.js +++ b/spec/index-spec.js @@ -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");