diff options
Diffstat (limited to 'src/ngScenario/matchers.js')
| -rw-r--r-- | src/ngScenario/matchers.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ngScenario/matchers.js b/src/ngScenario/matchers.js new file mode 100644 index 00000000..183dce46 --- /dev/null +++ b/src/ngScenario/matchers.js @@ -0,0 +1,45 @@ +'use strict'; + +/** + * Matchers for implementing specs. Follows the Jasmine spec conventions. + */ + +angular.scenario.matcher('toEqual', function(expected) { + return angular.equals(this.actual, expected); +}); + +angular.scenario.matcher('toBe', function(expected) { + return this.actual === expected; +}); + +angular.scenario.matcher('toBeDefined', function() { + return angular.isDefined(this.actual); +}); + +angular.scenario.matcher('toBeTruthy', function() { + return this.actual; +}); + +angular.scenario.matcher('toBeFalsy', function() { + return !this.actual; +}); + +angular.scenario.matcher('toMatch', function(expected) { + return new RegExp(expected).test(this.actual); +}); + +angular.scenario.matcher('toBeNull', function() { + return this.actual === null; +}); + +angular.scenario.matcher('toContain', function(expected) { + return includes(this.actual, expected); +}); + +angular.scenario.matcher('toBeLessThan', function(expected) { + return this.actual < expected; +}); + +angular.scenario.matcher('toBeGreaterThan', function(expected) { + return this.actual > expected; +}); |
