mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
refactoring done but Expect not working
This commit is contained in:
parent
e8b477f5b1
commit
ef88eb9a71
5 changed files with 18 additions and 16 deletions
|
|
@ -1,10 +1,10 @@
|
|||
function Matcher(future, logger) {
|
||||
var self = this;
|
||||
function Matcher(scope, future, logger) {
|
||||
var self = scope.$scenario = this;
|
||||
this.logger = logger;
|
||||
this.future = future;
|
||||
}
|
||||
|
||||
Matcher.addMatcher = function(name, matcher){
|
||||
Matcher.addMatcher = function(name, matcher) {
|
||||
Matcher.prototype[name] = function(expected) {
|
||||
var future = this.future;
|
||||
$scenario.addFuture(
|
||||
|
|
@ -18,4 +18,4 @@ Matcher.addMatcher = function(name, matcher){
|
|||
};
|
||||
};
|
||||
|
||||
Matcher.addMatcher('toEqual', function(a,b){ return a == b; });
|
||||
Matcher.addMatcher('toEqual', function(a,b) { return a == b; });
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ angular.scenario.Runner = function(scope, jQuery){
|
|||
this.scope.$testrun = {done: false, results: []};
|
||||
|
||||
var specs = this.specs = {};
|
||||
this.currentSpec = {name: '', futures: []};
|
||||
var path = [];
|
||||
this.scope.describe = function(name, body){
|
||||
path.push(name);
|
||||
|
|
@ -23,7 +24,7 @@ angular.scenario.Runner = function(scope, jQuery){
|
|||
afterEach = body;
|
||||
};
|
||||
this.scope.expect = function(future) {
|
||||
return new Matcher(future, self.logger);
|
||||
return new Matcher(self, future, self.logger);
|
||||
};
|
||||
this.scope.it = function(name, body) {
|
||||
var specName = path.join(' ') + ': it ' + name;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
describe("DSL", function() {
|
||||
|
||||
var scenario, runner, $scenario, lastDocument, executeFuture;
|
||||
var lastDocument, executeFuture, Expect;
|
||||
|
||||
beforeEach(function() {
|
||||
scenario = {};
|
||||
runner = new angular.scenario.Runner(scenario, _jQuery);
|
||||
$scenario = scenario.$scenario;
|
||||
setUpContext();
|
||||
executeFuture = function(future, html, callback) {
|
||||
lastDocument =_jQuery('<div>' + html + '</div>');
|
||||
_jQuery(document.body).append(lastDocument);
|
||||
|
|
@ -15,6 +13,7 @@ describe("DSL", function() {
|
|||
};
|
||||
future.behavior.call(specThis, callback || noop);
|
||||
};
|
||||
Expect = scenario.expect;
|
||||
});
|
||||
|
||||
describe("input", function() {
|
||||
|
|
@ -48,7 +47,7 @@ describe("DSL", function() {
|
|||
expect(future.name).toEqual("repeater '.repeater-row' count");
|
||||
executeFuture(future, "<div class='repeater-row'>a</div>" +
|
||||
"<div class='repeater-row'>b</div>");
|
||||
// Expect(future).toEqual(2);
|
||||
Expect(future).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
describe('Runner', function() {
|
||||
|
||||
var Describe, It, BeforeEach, AfterEach, body;
|
||||
|
||||
beforeEach(function() {
|
||||
setUpContext();
|
||||
Describe = scenario.describe;
|
||||
It = scenario.it;
|
||||
BeforeEach = scenario.beforeEach;
|
||||
AfterEach = scenario.afterEach;
|
||||
body = _jQuery('<div></div>');
|
||||
});
|
||||
|
||||
describe('describe', function() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var scenario, runner, log, $scenario, Describe, It, body;
|
||||
var scenario, runner, log, $scenario;
|
||||
|
||||
function logger(text) {
|
||||
return function(done){
|
||||
|
|
@ -11,10 +11,5 @@ function setUpContext() {
|
|||
scenario = {};
|
||||
runner = new angular.scenario.Runner(scenario, _jQuery);
|
||||
$scenario = scenario.$scenario;
|
||||
Describe = scenario.describe;
|
||||
BeforeEach = scenario.beforeEach;
|
||||
AfterEach = scenario.afterEach;
|
||||
It = scenario.it;
|
||||
log = '';
|
||||
body = _jQuery('<div></div>');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue