From ec0e1be095c462ecad1d28ddc9f5039eaa2a2749 Mon Sep 17 00:00:00 2001 From: deltreey Date: Mon, 24 Apr 2017 02:04:22 -0400 Subject: [PATCH] new tests to fix #2 by not breaking when initial tests fail in our recheck function --- karma-test/test.js | 12 ++++++++++++ test/test.js | 12 ++++++++++++ wildstring.js | 1 - 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/karma-test/test.js b/karma-test/test.js index c992d26..62aca3c 100644 --- a/karma-test/test.js +++ b/karma-test/test.js @@ -267,6 +267,18 @@ describe('wildstring - angular', function() { // Then: we should see that they match assert.equal(result, true); }); + + it('should be able to see the same character as a wildcard', function() { + // Given: a string with the same character multiple times, and a pattern with a wildcard and some of the same character + var pattern = '*zz', + string = 'zzz'; + + // When: we call wildstring.match + var result = wildstring.match(pattern, string); + + // Then: we should see that they match + assert.equal(result, true); + }); }); describe('#replace', function() { diff --git a/test/test.js b/test/test.js index 48fde54..53c6de7 100644 --- a/test/test.js +++ b/test/test.js @@ -261,6 +261,18 @@ describe('wildstring - node', function() { // Then: we should see that they match assert.equal(result, true); }); + + it('should be able to see the same character as a wildcard', function() { + // Given: a string with the same character multiple times, and a pattern with a wildcard and some of the same character + var pattern = '*zz', + string = 'zzz'; + + // When: we call wildstring.match + var result = wildstring.match(pattern, string); + + // Then: we should see that they match + assert.equal(result, true); + }); }); describe('#replace', function() { diff --git a/wildstring.js b/wildstring.js index 340cbe4..e93e500 100644 --- a/wildstring.js +++ b/wildstring.js @@ -30,7 +30,6 @@ var wildstring = { rollbackStrings.push({ string: testString, index: patternIndex }); if (testString.indexOf(patternSubstrings[patternIndex]) === -1) { rollbackStrings.pop(); - break; } currentString = currentString.substr(