Fix test which was causing the Chrome runner to fail. Upgraded JSTD to latest. Cleanup whitespace.

This commit is contained in:
Misko Hevery 2010-10-23 13:10:42 -07:00
parent 8a867cee22
commit 6ddcf91861
9 changed files with 52 additions and 50 deletions

Binary file not shown.

View file

@ -9,8 +9,8 @@ describe('angular.scenario.Application', function() {
it('should return new $window and $document after navigate', function() {
var testWindow, testDocument, counter = 0;
app.navigateTo = noop;
app.getWindow = function() {
return {x:counter++, document:{x:counter++}};
app.getWindow = function() {
return {x:counter++, document:{x:counter++}};
};
app.navigateTo('http://www.google.com/');
app.executeAction(function($document, $window) {
@ -26,8 +26,8 @@ describe('angular.scenario.Application', function() {
it('should execute callback with correct arguments', function() {
var testWindow = {document: {}};
app.getWindow = function() {
return testWindow;
app.getWindow = function() {
return testWindow;
};
app.executeAction(function($window, $document) {
expect(this).toEqual(app);
@ -35,7 +35,7 @@ describe('angular.scenario.Application', function() {
expect($window).toEqual(testWindow);
});
});
it('should create a new iframe each time', function() {
app.navigateTo('about:blank');
var frame = app.getFrame();
@ -43,27 +43,27 @@ describe('angular.scenario.Application', function() {
app.navigateTo('about:blank');
expect(app.getFrame().attr('test')).toBeFalsy();
});
it('should URL description bar', function() {
app.navigateTo('about:blank');
var anchor = frames.find('> h2 a');
expect(anchor.attr('href')).toEqual('about:blank');
expect(anchor.text()).toEqual('about:blank');
});
it('should call onload handler when frame loads', function() {
var called;
app.getFrame = function() {
// Mock a little jQuery
var result = {
remove: function() {
return result;
remove: function() {
return result;
},
attr: function(key, value) {
attr: function(key, value) {
return (!value) ? 'attribute value' : result;
},
load: function() {
called = true;
load: function() {
called = true;
}
};
return result;

View file

@ -4,21 +4,21 @@ describe('angular.scenario.Describe', function() {
beforeEach(function() {
root = new angular.scenario.Describe();
/**
* Simple callback logging system. Use to assert proper order of calls.
*/
log = function(text) {
log.text = log.text + text;
log = function(text) {
log.text = log.text + text;
};
log.fn = function(text) {
return function(done){
log(text);
(done || angular.noop)();
return function(done){
log(text);
(done || angular.noop)();
};
};
log.reset = function() {
log.text = '';
log.reset = function() {
log.text = '';
};
log.reset();
});
@ -50,7 +50,7 @@ describe('angular.scenario.Describe', function() {
specs[1].after();
expect(log.text).toEqual('{1}');
});
it('should link nested describe blocks with parent and children', function() {
root.describe('A', function() {
this.it('1', angular.noop);
@ -65,7 +65,7 @@ describe('angular.scenario.Describe', function() {
expect(specs[2].definition.parent).toEqual(root);
expect(specs[0].definition.parent).toEqual(specs[2].definition.children[0]);
});
it('should not process xit and xdescribe', function() {
root.describe('A', function() {
this.xit('1', angular.noop);
@ -79,7 +79,7 @@ describe('angular.scenario.Describe', function() {
var specs = root.getSpecs();
expect(specs.length).toEqual(0);
});
it('should create uniqueIds in the tree', function() {
angular.scenario.Describe.id = 0;
var a = new angular.scenario.Describe();

View file

@ -1,6 +1,6 @@
describe('angular.scenario.Future', function() {
var future;
it('should set the sane defaults', function() {
var behavior = function() {};
var future = new angular.scenario.Future('test name', behavior, 'foo');
@ -11,7 +11,7 @@ describe('angular.scenario.Future', function() {
expect(future.fulfilled).toBeFalsy();
expect(future.parser).toEqual(angular.identity);
});
it('should be fulfilled after execution and done callback', function() {
var future = new angular.scenario.Future('test name', function(done) {
done();
@ -19,7 +19,7 @@ describe('angular.scenario.Future', function() {
future.execute(angular.noop);
expect(future.fulfilled).toBeTruthy();
});
it('should take callback with (error, result) and forward', function() {
var future = new angular.scenario.Future('test name', function(done) {
done(10, 20);
@ -29,7 +29,7 @@ describe('angular.scenario.Future', function() {
expect(result).toEqual(20);
});
});
it('should use error as value if provided', function() {
var future = new angular.scenario.Future('test name', function(done) {
done(10, 20);
@ -37,7 +37,7 @@ describe('angular.scenario.Future', function() {
future.execute(angular.noop);
expect(future.value).toEqual(10);
});
it('should parse json with fromJson', function() {
var future = new angular.scenario.Future('test name', function(done) {
done(null, "{test: 'foo'}");
@ -45,7 +45,7 @@ describe('angular.scenario.Future', function() {
future.fromJson().execute(angular.noop);
expect(future.value).toEqual({test: 'foo'});
});
it('should convert to json with toJson', function() {
var future = new angular.scenario.Future('test name', function(done) {
done(null, {test: 'foo'});
@ -53,7 +53,7 @@ describe('angular.scenario.Future', function() {
future.toJson().execute(angular.noop);
expect(future.value).toEqual('{"test":"foo"}');
});
it('should convert with custom parser', function() {
var future = new angular.scenario.Future('test name', function(done) {
done(null, 'foo');
@ -63,7 +63,7 @@ describe('angular.scenario.Future', function() {
}).execute(angular.noop);
expect(future.value).toEqual('FOO');
});
it('should pass error if parser fails', function() {
var future = new angular.scenario.Future('test name', function(done) {
done(null, '{');
@ -71,5 +71,5 @@ describe('angular.scenario.Future', function() {
future.fromJson().execute(function(error, result) {
expect(error).toBeDefined();
});
});
});
});

View file

@ -2,7 +2,7 @@ describe('angular.scenario.HtmlUI', function() {
var ui;
var context;
var spec;
function line() { return 'unknown:-1'; }
beforeEach(function() {
@ -85,7 +85,7 @@ describe('angular.scenario.HtmlUI', function() {
expect(timer.innerHTML).toMatch(/ms$/);
});
});
it('should include line if provided', function() {
specUI = ui.addSpec(spec);
specUI.addStep('some step', line).finish('error!');

View file

@ -16,7 +16,7 @@ MockSpecRunner.prototype.addFuture = function(name, fn, line) {
describe('angular.scenario.Runner', function() {
var $window;
var runner;
beforeEach(function() {
// Trick to get the scope out of a DSL statement
angular.scenario.dsl('dslAddFuture', function() {
@ -42,12 +42,12 @@ describe('angular.scenario.Runner', function() {
};
runner = new angular.scenario.Runner($window);
});
afterEach(function() {
delete angular.scenario.dsl.dslScope;
delete angular.scenario.dsl.dslChain;
});
it('should publish the functions in the public API', function() {
angular.foreach(runner.api, function(fn, name) {
var func;
@ -57,7 +57,7 @@ describe('angular.scenario.Runner', function() {
expect(angular.isFunction(func)).toBeTruthy();
});
});
it('should construct valid describe trees with public API', function() {
var before = [];
var after = [];
@ -85,7 +85,7 @@ describe('angular.scenario.Runner', function() {
expect(specs[2].definition.parent).toEqual(runner.rootDescribe);
expect(specs[0].definition.parent).toEqual(specs[2].definition.children[0]);
});
it('should publish the DSL statements to the $window', function() {
$window.describe('describe', function() {
$window.it('1', function() {
@ -94,7 +94,7 @@ describe('angular.scenario.Runner', function() {
});
runner.run(null/*ui*/, null/*application*/, MockSpecRunner, rethrow);
});
it('should create a new scope for each DSL chain', function() {
$window.describe('describe', function() {
$window.it('1', function() {

View file

@ -49,7 +49,7 @@ ApplicationMock.prototype = {
describe('angular.scenario.SpecRunner', function() {
var $window;
var runner;
function createSpec(name, body) {
return {
name: name,
@ -93,8 +93,8 @@ describe('angular.scenario.SpecRunner', function() {
it('should execute spec function and notify UI', function() {
var finished;
var ui = new UIMock();
var spec = createSpec('test spec', function() {
this.test = 'some value';
var spec = createSpec('test spec', function() {
this.test = 'some value';
});
runner.addFuture('test future', function(done) {
done();
@ -115,7 +115,7 @@ describe('angular.scenario.SpecRunner', function() {
it('should execute notify UI on spec setup error', function() {
var finished;
var ui = new UIMock();
var spec = createSpec('test spec', function() {
var spec = createSpec('test spec', function() {
throw 'message';
});
runner.run(ui, spec, function() {
@ -166,7 +166,7 @@ describe('angular.scenario.SpecRunner', function() {
'spec finish:'
]);
});
it('should run after handlers even if error in body of spec', function() {
var finished, after;
var ui = new UIMock();

View file

@ -190,7 +190,9 @@ describe("angular.scenario.dsl", function() {
describe('Element', function() {
it('should execute click', function() {
var clicked;
doc.append('<a href=""></a>');
// Hash is important, otherwise we actually
// go to a different page and break the runner
doc.append('<a href="#"></a>');
doc.find('a').click(function() {
clicked = true;
});

View file

@ -1,6 +1,6 @@
describe('angular.scenario.matchers', function () {
var matchers;
function expectMatcher(value, test) {
delete matchers.error;
delete matchers.future.value;
@ -10,9 +10,9 @@ describe('angular.scenario.matchers', function () {
test();
expect(matchers.error).toBeUndefined();
}
beforeEach(function() {
/**
/**
* Mock up the future system wrapped around matchers.
*
* @see Scenario.js#angular.scenario.matcher
@ -27,7 +27,7 @@ describe('angular.scenario.matchers', function () {
};
angular.extend(matchers, angular.scenario.matcher);
});
it('should handle basic matching', function() {
expectMatcher(10, function() { matchers.toEqual(10); });
expectMatcher('value', function() { matchers.toBeDefined(); });