mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
before pulling testcontext out
This commit is contained in:
parent
da95010350
commit
32c4aee1cd
4 changed files with 64 additions and 86 deletions
|
|
@ -11,25 +11,3 @@ Future.prototype = {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function Matcher(future, logger) {
|
|
||||||
var self = this;
|
|
||||||
this.logger = logger;
|
|
||||||
this.future = future;
|
|
||||||
}
|
|
||||||
|
|
||||||
Matcher.addMatcher = function(name, matcher){
|
|
||||||
Matcher.prototype[name] = function(expected) {
|
|
||||||
var future = this.future;
|
|
||||||
$scenario.addFuture(
|
|
||||||
'expect ' + future.name + ' ' + name + ' ' + expected,
|
|
||||||
function(done){
|
|
||||||
if (matcher(future.value, expected))
|
|
||||||
throw "Expected " + expected + ' but was ' + future.value;
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
Matcher.addMatcher('toEqual', function(a,b){ return a == b; });
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
//function Matcher(future, logger) {
|
function Matcher(future, logger) {
|
||||||
// var self = this;
|
var self = this;
|
||||||
// this.logger = logger;
|
this.logger = logger;
|
||||||
// this.future = future;
|
this.future = future;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//Matcher.addMatcher = function(name, matcher){
|
Matcher.addMatcher = function(name, matcher){
|
||||||
// Matcher.prototype[name] = function(expected) {
|
Matcher.prototype[name] = function(expected) {
|
||||||
// var future = this.future;
|
var future = this.future;
|
||||||
// $scenario.addFuture(
|
$scenario.addFuture(
|
||||||
// 'expect ' + future.name + ' ' + name + ' ' + expected,
|
'expect ' + future.name + ' ' + name + ' ' + expected,
|
||||||
// function(done){
|
function(done){
|
||||||
// if (matcher(future.value, expected))
|
if (matcher(future.value, expected))
|
||||||
// throw "Expected " + expected + ' but was ' + future.value;
|
throw "Expected " + expected + ' but was ' + future.value;
|
||||||
// done();
|
done();
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// };
|
};
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
//Matcher.addMatcher('toEqual', function(a,b){ return a == b; });
|
Matcher.addMatcher('toEqual', function(a,b){ return a == b; });
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ angular.scenario.Runner = function(scope, jQuery){
|
||||||
this.scope.afterEach = function(body) {
|
this.scope.afterEach = function(body) {
|
||||||
afterEach = body;
|
afterEach = body;
|
||||||
};
|
};
|
||||||
// this.scope.expect = function(future) {
|
this.scope.expect = function(future) {
|
||||||
// return new Matcher(future, self.logger);
|
return new Matcher(future, self.logger);
|
||||||
// };
|
};
|
||||||
this.scope.it = function(name, body) {
|
this.scope.it = function(name, body) {
|
||||||
var specName = path.join(' ') + ': it ' + name;
|
var specName = path.join(' ') + ': it ' + name;
|
||||||
self.currentSpec = specs[specName] = {
|
self.currentSpec = specs[specName] = {
|
||||||
|
|
|
||||||
|
|
@ -204,45 +204,45 @@ describe('Runner', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// describe('run', function() {
|
describe('run', function() {
|
||||||
// var next;
|
var next;
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// Describe('d1', function() {
|
Describe('d1', function() {
|
||||||
// It('it1', function() { $scenario.addFuture('s1', logger('s1,')); });
|
It('it1', function() { $scenario.addFuture('s1', logger('s1,')); });
|
||||||
// It('it2', function() {
|
It('it2', function() {
|
||||||
// $scenario.addFuture('s2', logger('s2,'));
|
$scenario.addFuture('s2', logger('s2,'));
|
||||||
// $scenario.addFuture('s2.2', function(done){ next = done; });
|
$scenario.addFuture('s2.2', function(done){ next = done; });
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// Describe('d2', function() {
|
Describe('d2', function() {
|
||||||
// It('it3', function() { $scenario.addFuture('s3', logger('s3,')); });
|
It('it3', function() { $scenario.addFuture('s3', logger('s3,')); });
|
||||||
// It('it4', function() { $scenario.addFuture('s4', logger('s4,')); });
|
It('it4', function() { $scenario.addFuture('s4', logger('s4,')); });
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// it('should execute all specs', function() {
|
it('should execute all specs', function() {
|
||||||
// $scenario.run(body);
|
$scenario.run(body);
|
||||||
//
|
|
||||||
// expect(log).toEqual('s1,s2,');
|
expect(log).toEqual('s1,s2,');
|
||||||
// next();
|
next();
|
||||||
// expect(log).toEqual('s1,s2,s3,s4,');
|
expect(log).toEqual('s1,s2,s3,s4,');
|
||||||
// });
|
});
|
||||||
// it('should publish done state and results as tests are run', function() {
|
it('should publish done state and results as tests are run', function() {
|
||||||
// expect(scenario.$testrun.done).toBeFalsy();
|
expect(scenario.$testrun.done).toBeFalsy();
|
||||||
// expect(scenario.$testrun.results).toEqual([]);
|
expect(scenario.$testrun.results).toEqual([]);
|
||||||
// $scenario.run(body);
|
$scenario.run(body);
|
||||||
// expect(scenario.$testrun.done).toBeFalsy();
|
expect(scenario.$testrun.done).toBeFalsy();
|
||||||
// expect(scenario.$testrun.results).toEqual([
|
expect(scenario.$testrun.results).toEqual([
|
||||||
// {name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']}
|
{name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']}
|
||||||
// ]);
|
]);
|
||||||
// next();
|
next();
|
||||||
// expect(scenario.$testrun.done).toBeTruthy();
|
expect(scenario.$testrun.done).toBeTruthy();
|
||||||
// expect(scenario.$testrun.results).toEqual([
|
expect(scenario.$testrun.results).toEqual([
|
||||||
// {name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']},
|
{name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']},
|
||||||
// {name: 'd1: it it2', passed: true, error: undefined, steps: ['s2', 's2.2']},
|
{name: 'd1: it it2', passed: true, error: undefined, steps: ['s2', 's2.2']},
|
||||||
// {name: 'd2: it it3', passed: true, error: undefined, steps: ['s3']},
|
{name: 'd2: it it3', passed: true, error: undefined, steps: ['s3']},
|
||||||
// {name: 'd2: it it4', passed: true, error: undefined, steps: ['s4']}
|
{name: 'd2: it it4', passed: true, error: undefined, steps: ['s4']}
|
||||||
// ]);
|
]);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue