mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-22 01:10:23 +00:00
the flag must be in all src and test files so that we get the benefit of running in the strict mode even in jstd the following script was used to modify all files: for file in `find src test -name "*.js"`; do echo -e "'use strict';\n" > temp.txt cat $file >> temp.txt mv temp.txt $file done
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
describe('angular.scenario.matchers', function () {
|
|
var matchers;
|
|
|
|
function expectMatcher(value, test) {
|
|
delete matchers.error;
|
|
delete matchers.future.value;
|
|
if (value !== undefined) {
|
|
matchers.future.value = value;
|
|
}
|
|
test();
|
|
expect(matchers.error).toBeUndefined();
|
|
}
|
|
|
|
beforeEach(function() {
|
|
/**
|
|
* Mock up the future system wrapped around matchers.
|
|
*
|
|
* @see Scenario.js#angular.scenario.matcher
|
|
*/
|
|
matchers = {
|
|
future: { name: 'test' }
|
|
};
|
|
matchers.addFuture = function(name, callback) {
|
|
callback(function(error) {
|
|
matchers.error = error;
|
|
});
|
|
};
|
|
angular.extend(matchers, angular.scenario.matcher);
|
|
});
|
|
|
|
it('should handle basic matching', function() {
|
|
expectMatcher(10, function() { matchers.toEqual(10); });
|
|
expectMatcher('value', function() { matchers.toBeDefined(); });
|
|
expectMatcher([1], function() { matchers.toBeTruthy(); });
|
|
expectMatcher("", function() { matchers.toBeFalsy(); });
|
|
expectMatcher(0, function() { matchers.toBeFalsy(); });
|
|
expectMatcher('foo', function() { matchers.toMatch('.o.'); });
|
|
expectMatcher(null, function() { matchers.toBeNull(); });
|
|
expectMatcher([1, 2, 3], function() { matchers.toContain(2); });
|
|
expectMatcher(3, function() { matchers.toBeLessThan(10); });
|
|
expectMatcher(3, function() { matchers.toBeGreaterThan(-5); });
|
|
});
|
|
});
|