From c5c44b9d0c22727ebd6640fdb3cd8c8c26b43d5a Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 16 Jan 2015 15:42:32 +0100 Subject: [PATCH] Behavior specs cleanup: Improve text specs --- spec/behavior/generated-parser-behavior.spec.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spec/behavior/generated-parser-behavior.spec.js b/spec/behavior/generated-parser-behavior.spec.js index ac9e278..10300ef 100644 --- a/spec/behavior/generated-parser-behavior.spec.js +++ b/spec/behavior/generated-parser-behavior.spec.js @@ -664,10 +664,20 @@ describe("generated parser behavior", function() { }); describe("text", function() { - it("matches correctly", function() { - var parser = PEG.buildParser('start = $("a" "b" "c")', options); + describe("when the expression matches", function() { + it("returns the matched text", function() { + var parser = PEG.buildParser('start = $("a" "b" "c")', options); - expect(parser).toParse("abc", "abc"); + expect(parser).toParse("abc", "abc"); + }); + }); + + describe("when the expression doesn't match", function() { + it("reports match failure", function() { + var parser = PEG.buildParser('start = $("a")', options); + + expect(parser).toFailToParse("b"); + }); }); });