Skip to content

Commit

Permalink
feat: Values now use public Matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed Sep 29, 2019
1 parent 78fb265 commit 0336468
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/values/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ export class LanguageSpecificValue<V> {
/**
* Create a matcher function for this value and the specified language.
*
* @param {Language} language
* @param language
*/
public matcher(language: Language) {
public matcher(language: Language): Matcher<V> {
const value = this.factory(language);

return function(text: string, options?: EncounterOptions) {
return value.matcher.match(text, options);
};
return value.matcher;
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/value-matchers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ describe('Value: Matchers', () => {

it('Can parse string', () => {
const matcher = booleanValue().matcher(en);
return matcher('yes')
return matcher.match('yes')
.then(v => expect(v).toEqual(true));
});

it('Can handle invalid value', () => {
const matcher = booleanValue().matcher(en);
return matcher('cookies')
return matcher.match('cookies')
.then(v => expect(v).toEqual(null));
});

Expand Down

0 comments on commit 0336468

Please sign in to comment.