mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-03 20:54:43 +00:00
semi working state
This commit is contained in:
parent
5215e2095c
commit
e3368e12a6
3 changed files with 55 additions and 26 deletions
|
|
@ -29,13 +29,24 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li.running > span {
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////
|
#runner span {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
.collapsed .log {
|
#runner .fail > span {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.collapsed > ul {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////
|
||||||
|
|
||||||
.run, .info, .error {
|
.run, .info, .error {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 0 1em;
|
padding: 0 1em;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ angular.scenario.Runner = function(scope){
|
||||||
body();
|
body();
|
||||||
self.currentSpec = null;
|
self.currentSpec = null;
|
||||||
};
|
};
|
||||||
this.beginSpec = function returnNoop(){
|
this.logger = function returnNoop(){
|
||||||
return returnNoop;
|
return angular.extend(returnNoop, {close:angular.noop, fail:angular.noop});;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -29,33 +29,45 @@ angular.scenario.Runner.prototype = {
|
||||||
run: function(body){
|
run: function(body){
|
||||||
body.append(
|
body.append(
|
||||||
'<div id="runner">' +
|
'<div id="runner">' +
|
||||||
'<ul class="console"></ul>' +
|
'<div class="console"></div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div id="testView">' +
|
'<div id="testView">' +
|
||||||
'<iframe></iframe>' +
|
'<iframe></iframe>' +
|
||||||
'</div>');
|
'</div>');
|
||||||
var console = body.find('#runner .console');
|
var console = body.find('#runner .console');
|
||||||
|
console.find('li').live('click', function(){
|
||||||
|
jQuery(this).toggleClass('collapsed');
|
||||||
|
});
|
||||||
this.testFrame = body.find('#testView iframe');
|
this.testFrame = body.find('#testView iframe');
|
||||||
this.testWindow = this.testFrame[0].contentWindow;
|
this.testWindow = this.testFrame[0].contentWindow;
|
||||||
this.beginSpec = function(name){
|
function logger(parent) {
|
||||||
var specElement = jQuery('<li class="spec"></li>');
|
var container;
|
||||||
var stepContainer = jQuery('<ul class="step"></ul>');
|
return function(type, text) {
|
||||||
console.append(specElement);
|
if (!container) {
|
||||||
specElement.text(name);
|
container = jQuery('<ul></ul>');
|
||||||
specElement.append(stepContainer);
|
parent.append(container);
|
||||||
return function(name){
|
}
|
||||||
var stepElement = jQuery('<li class="step"></li>');
|
var element = jQuery('<li class="collapsed running '+type+'"><span></span></li>');
|
||||||
var logContainer = jQuery('<ul class="log"></ul>');
|
element.find('span').text(text);
|
||||||
stepContainer.append(stepElement);
|
container.append(element);
|
||||||
stepElement.text(name);
|
return angular.extend(logger(element), {
|
||||||
stepElement.append(logContainer);
|
close: function(){
|
||||||
return function(message) {
|
element.removeClass('running');
|
||||||
var logElement = jQuery('<li class="log"></li>');
|
},
|
||||||
logContainer.append(logElement);
|
fail: function(){
|
||||||
logElement.text(message);
|
element.removeClass('running');
|
||||||
};
|
var current = element;
|
||||||
|
while (current[0] != console[0]) {
|
||||||
|
if (current.is('li'))
|
||||||
|
current.addClass('fail');
|
||||||
|
current.removeClass('collapsed');
|
||||||
|
current = current.parent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
this.logger = logger(console);
|
||||||
this.execute("widgets: it should verify that basic widgets work");
|
this.execute("widgets: it should verify that basic widgets work");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -73,7 +85,7 @@ angular.scenario.Runner.prototype = {
|
||||||
result.passed = false;
|
result.passed = false;
|
||||||
result.failed = true;
|
result.failed = true;
|
||||||
result.error = error;
|
result.error = error;
|
||||||
result.log(angular.isString(error) ? error : angular.toJson(error));
|
result.log('fail', angular.isString(error) ? error : angular.toJson(error)).fail();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
specThis = {
|
specThis = {
|
||||||
|
|
@ -81,17 +93,20 @@ angular.scenario.Runner.prototype = {
|
||||||
testWindow: this.testWindow,
|
testWindow: this.testWindow,
|
||||||
testFrame: this.testFrame
|
testFrame: this.testFrame
|
||||||
};
|
};
|
||||||
var beginStep = this.beginSpec(name);
|
var stepLogger = this.logger('spec', name);
|
||||||
spec.nextStepIndex = 0;
|
spec.nextStepIndex = 0;
|
||||||
function done() {
|
function done() {
|
||||||
result.finished = true;
|
result.finished = true;
|
||||||
|
stepLogger.close();
|
||||||
(callback||angular.noop).call(specThis);
|
(callback||angular.noop).call(specThis);
|
||||||
}
|
}
|
||||||
function next(){
|
function next(){
|
||||||
var step = spec.steps[spec.nextStepIndex];
|
var step = spec.steps[spec.nextStepIndex];
|
||||||
|
(result.log || {close:angular.noop}).close();
|
||||||
|
result.log = null;
|
||||||
if (step) {
|
if (step) {
|
||||||
spec.nextStepIndex ++;
|
spec.nextStepIndex ++;
|
||||||
result.log = beginStep(step.name);
|
result.log = stepLogger('step', step.name);
|
||||||
try {
|
try {
|
||||||
step.fn.call(specThis, next);
|
step.fn.call(specThis, next);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ describe('Runner', function(){
|
||||||
expect(spec.steps).toEqual([]);
|
expect(spec.steps).toEqual([]);
|
||||||
expect(spec.name).toEqual('describe name: it should text');
|
expect(spec.name).toEqual('describe name: it should text');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should camplain on duplicate it', angular.noop);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue