diff --git a/spec/behavior/generated-parser-behavior.spec.js b/spec/behavior/generated-parser-behavior.spec.js index fc54a9d..bc724aa 100644 --- a/spec/behavior/generated-parser-behavior.spec.js +++ b/spec/behavior/generated-parser-behavior.spec.js @@ -615,11 +615,20 @@ describe("generated parser behavior", function() { }); describe("optional", function() { - it("matches correctly", function() { - var parser = PEG.buildParser('start = "a"?', options); + describe("when the expression matches", function() { + it("returns its match result", function() { + var parser = PEG.buildParser('start = "a"?', options); - expect(parser).toParse("", null); - expect(parser).toParse("a", "a"); + expect(parser).toParse("a", "a"); + }); + }); + + describe("when the expression doesn't match", function() { + it("returns |null|", function() { + var parser = PEG.buildParser('start = "a"?', options); + + expect(parser).toParse("", null); + }); }); });