2010-10-08 23:43:40 +00:00
|
|
|
describe("angular.scenario.dsl", function() {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
var $window, $root;
|
|
|
|
|
var application, eventLog;
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
beforeEach(function() {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
eventLog = [];
|
2010-10-08 23:43:40 +00:00
|
|
|
$window = {
|
|
|
|
|
document: _jQuery("<div></div>"),
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
angular: new angular.scenario.testing.MockAngular()
|
2010-10-08 23:43:40 +00:00
|
|
|
};
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
$root = angular.scope({
|
|
|
|
|
emit: function(eventName) {
|
|
|
|
|
eventLog.push(eventName);
|
|
|
|
|
},
|
|
|
|
|
on: function(eventName) {
|
|
|
|
|
eventLog.push('Listener Added for ' + eventName);
|
|
|
|
|
}
|
|
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
$root.futures = [];
|
2010-10-19 20:17:49 +00:00
|
|
|
$root.futureLog = [];
|
|
|
|
|
$root.$window = $window;
|
2010-10-08 23:43:40 +00:00
|
|
|
$root.addFuture = function(name, fn) {
|
|
|
|
|
this.futures.push(name);
|
|
|
|
|
fn.call(this, function(error, result) {
|
|
|
|
|
$root.futureError = error;
|
|
|
|
|
$root.futureResult = result;
|
2010-10-19 20:17:49 +00:00
|
|
|
$root.futureLog.push(name);
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
|
|
|
|
};
|
2010-10-18 21:02:18 +00:00
|
|
|
$root.dsl = {};
|
|
|
|
|
angular.foreach(angular.scenario.dsl, function(fn, name) {
|
|
|
|
|
$root.dsl[name] = function() {
|
|
|
|
|
return fn.call($root).apply($root, arguments);
|
|
|
|
|
};
|
|
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
$root.application = new angular.scenario.Application($window.document);
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
$root.application.getWindow_ = function() {
|
2010-10-15 20:44:53 +00:00
|
|
|
return $window;
|
2010-10-08 23:43:40 +00:00
|
|
|
};
|
2010-10-15 20:44:53 +00:00
|
|
|
$root.application.navigateTo = function(url, callback) {
|
2010-10-08 23:43:40 +00:00
|
|
|
$window.location = url;
|
|
|
|
|
callback();
|
|
|
|
|
};
|
|
|
|
|
// Just use the real one since it delegates to this.addFuture
|
|
|
|
|
$root.addFutureAction = angular.scenario.
|
|
|
|
|
SpecRunner.prototype.addFutureAction;
|
2010-08-13 16:31:06 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
describe('Wait', function() {
|
|
|
|
|
it('should wait until resume to complete', function() {
|
|
|
|
|
expect($window.resume).toBeUndefined();
|
|
|
|
|
$root.dsl.wait();
|
|
|
|
|
expect(angular.isFunction($window.resume)).toBeTruthy();
|
|
|
|
|
expect($root.futureLog).toEqual([]);
|
|
|
|
|
$window.resume();
|
|
|
|
|
expect($root.futureLog).
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
toEqual(['waiting for you to resume']);
|
|
|
|
|
expect(eventLog).toContain('InteractiveWait');
|
2010-10-19 20:17:49 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
describe('Pause', function() {
|
2010-08-11 02:10:43 +00:00
|
|
|
beforeEach(function() {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
$root.$window.setTimeout = function(fn, value) {
|
2010-10-08 23:43:40 +00:00
|
|
|
$root.timerValue = value;
|
|
|
|
|
fn();
|
|
|
|
|
};
|
2010-08-11 02:10:43 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
it('should pause for specified seconds', function() {
|
2010-10-18 21:02:18 +00:00
|
|
|
$root.dsl.pause(10);
|
2010-10-08 23:43:40 +00:00
|
|
|
expect($root.timerValue).toEqual(10000);
|
|
|
|
|
expect($root.futureResult).toEqual(10000);
|
2010-10-15 20:44:53 +00:00
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
describe('Expect', function() {
|
|
|
|
|
it('should chain and execute matcher', function() {
|
|
|
|
|
var future = {value: 10};
|
2010-10-18 21:02:18 +00:00
|
|
|
var result = $root.dsl.expect(future);
|
2010-10-08 23:43:40 +00:00
|
|
|
result.toEqual(10);
|
|
|
|
|
expect($root.futureError).toBeUndefined();
|
|
|
|
|
expect($root.futureResult).toBeUndefined();
|
2010-10-18 21:02:18 +00:00
|
|
|
result = $root.dsl.expect(future);
|
2010-10-08 23:43:40 +00:00
|
|
|
result.toEqual(20);
|
|
|
|
|
expect($root.futureError).toBeDefined();
|
2010-06-09 19:35:40 +00:00
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-29 23:02:57 +00:00
|
|
|
describe('Browser', function() {
|
2010-11-02 00:24:24 +00:00
|
|
|
describe('Reload', function() {
|
|
|
|
|
it('should navigateTo', function() {
|
|
|
|
|
$window.location = {
|
|
|
|
|
href: '#foo'
|
|
|
|
|
};
|
|
|
|
|
$root.dsl.browser().reload();
|
|
|
|
|
expect($root.futureResult).toEqual('#foo');
|
|
|
|
|
expect($window.location).toEqual('#foo');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-29 23:02:57 +00:00
|
|
|
describe('NavigateTo', function() {
|
|
|
|
|
it('should allow a string url', function() {
|
|
|
|
|
$root.dsl.browser().navigateTo('http://myurl');
|
|
|
|
|
expect($window.location).toEqual('http://myurl');
|
|
|
|
|
expect($root.futureResult).toEqual('http://myurl');
|
|
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-29 23:02:57 +00:00
|
|
|
it('should allow a future url', function() {
|
|
|
|
|
$root.dsl.browser().navigateTo('http://myurl', function() {
|
|
|
|
|
return 'http://futureUrl/';
|
|
|
|
|
});
|
|
|
|
|
expect($window.location).toEqual('http://futureUrl/');
|
|
|
|
|
expect($root.futureResult).toEqual('http://futureUrl/');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should complete if angular is missing from app frame', function() {
|
|
|
|
|
delete $window.angular;
|
|
|
|
|
$root.dsl.browser().navigateTo('http://myurl');
|
|
|
|
|
expect($window.location).toEqual('http://myurl');
|
|
|
|
|
expect($root.futureResult).toEqual('http://myurl');
|
2010-10-19 20:17:49 +00:00
|
|
|
});
|
2010-08-11 02:10:43 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-29 23:02:57 +00:00
|
|
|
describe('Location', function() {
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
$window.location = {
|
|
|
|
|
href: 'http://myurl/some/path?foo=10#/bar?x=2',
|
|
|
|
|
pathname: '/some/path',
|
|
|
|
|
search: '?foo=10',
|
|
|
|
|
hash: '#bar?x=2'
|
|
|
|
|
};
|
|
|
|
|
$window.angular.scope = function() {
|
|
|
|
|
return {
|
|
|
|
|
$location: {
|
|
|
|
|
hashSearch: {x: 2},
|
|
|
|
|
hashPath: '/bar',
|
|
|
|
|
search: {foo: 10}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return full URL for href', function() {
|
|
|
|
|
$root.dsl.browser().location().href();
|
|
|
|
|
expect($root.futureResult).toEqual($window.location.href);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the pathname', function() {
|
|
|
|
|
$root.dsl.browser().location().path();
|
|
|
|
|
expect($root.futureResult).toEqual($window.location.pathname);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the hash without the #', function() {
|
|
|
|
|
$root.dsl.browser().location().hash();
|
|
|
|
|
expect($root.futureResult).toEqual('bar?x=2');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the query string as an object', function() {
|
|
|
|
|
$root.dsl.browser().location().search();
|
|
|
|
|
expect($root.futureResult).toEqual({foo: 10});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the hashSearch as an object', function() {
|
|
|
|
|
$root.dsl.browser().location().hashSearch();
|
|
|
|
|
expect($root.futureResult).toEqual({x: 2});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the hashPath', function() {
|
|
|
|
|
$root.dsl.browser().location().hashPath();
|
|
|
|
|
expect($root.futureResult).toEqual('/bar');
|
|
|
|
|
});
|
2010-08-07 00:28:47 +00:00
|
|
|
});
|
2010-06-09 19:35:40 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
describe('Element Finding', function() {
|
|
|
|
|
var doc;
|
|
|
|
|
//TODO(esprehn): Work around a bug in jQuery where attribute selectors
|
|
|
|
|
// only work if they are executed on a real document, not an element.
|
|
|
|
|
//
|
|
|
|
|
// ex. jQuery('#foo').find('[name="bar"]') // fails
|
|
|
|
|
// ex. jQuery('#foo [name="bar"]') // works, wtf?
|
|
|
|
|
//
|
2010-08-10 00:55:01 +00:00
|
|
|
beforeEach(function() {
|
2010-10-08 23:43:40 +00:00
|
|
|
doc = _jQuery('<div id="angular-scenario-binding"></div>');
|
2010-10-15 20:44:53 +00:00
|
|
|
_jQuery(document.body).html('').append(doc);
|
2010-10-08 23:43:40 +00:00
|
|
|
$window.document = window.document;
|
2010-08-10 00:55:01 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
afterEach(function() {
|
2010-10-15 20:44:53 +00:00
|
|
|
_jQuery(document.body).
|
|
|
|
|
find('#angular-scenario-binding').
|
|
|
|
|
remove();
|
2010-08-10 00:55:01 +00:00
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
describe('Select', function() {
|
|
|
|
|
it('should select single option', function() {
|
|
|
|
|
doc.append(
|
|
|
|
|
'<select name="test">' +
|
|
|
|
|
' <option>A</option>' +
|
|
|
|
|
' <option selected>B</option>' +
|
|
|
|
|
'</select>'
|
|
|
|
|
);
|
|
|
|
|
$root.dsl.select('test').option('A');
|
|
|
|
|
expect(_jQuery('[name="test"]').val()).toEqual('A');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should select multiple options', function() {
|
|
|
|
|
doc.append(
|
|
|
|
|
'<select name="test" multiple>' +
|
|
|
|
|
' <option>A</option>' +
|
|
|
|
|
' <option selected>B</option>' +
|
|
|
|
|
' <option>C</option>' +
|
|
|
|
|
'</select>'
|
|
|
|
|
);
|
|
|
|
|
$root.dsl.select('test').options('A', 'B');
|
|
|
|
|
expect(_jQuery('[name="test"]').val()).toEqual(['A','B']);
|
|
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should fail to select multiple options on non-multiple select', function() {
|
|
|
|
|
doc.append('<select name="test"></select>');
|
|
|
|
|
$root.dsl.select('test').options('A', 'B');
|
|
|
|
|
expect($root.futureError).toMatch(/did not match/);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Element', function() {
|
|
|
|
|
it('should execute click', function() {
|
|
|
|
|
var clicked;
|
2010-10-23 20:10:42 +00:00
|
|
|
// Hash is important, otherwise we actually
|
|
|
|
|
// go to a different page and break the runner
|
|
|
|
|
doc.append('<a href="#"></a>');
|
2010-10-18 21:02:18 +00:00
|
|
|
doc.find('a').click(function() {
|
|
|
|
|
clicked = true;
|
|
|
|
|
});
|
|
|
|
|
$root.dsl.element('a').click();
|
|
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
it('should navigate page if click on anchor', function() {
|
|
|
|
|
expect($window.location).not.toEqual('#foo');
|
|
|
|
|
doc.append('<a href="#foo"></a>');
|
|
|
|
|
$root.dsl.element('a').click();
|
2010-10-26 22:35:58 +00:00
|
|
|
expect($window.location).toMatch(/#foo$/);
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should count matching elements', function() {
|
|
|
|
|
doc.append('<span></span><span></span>');
|
|
|
|
|
$root.dsl.element('span').count();
|
|
|
|
|
expect($root.futureResult).toEqual(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return count of 0 if no matching elements', function() {
|
|
|
|
|
$root.dsl.element('span').count();
|
|
|
|
|
expect($root.futureResult).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should get attribute', function() {
|
|
|
|
|
doc.append('<div id="test" class="foo"></div>');
|
|
|
|
|
$root.dsl.element('#test').attr('class');
|
|
|
|
|
expect($root.futureResult).toEqual('foo');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should set attribute', function() {
|
|
|
|
|
doc.append('<div id="test" class="foo"></div>');
|
|
|
|
|
$root.dsl.element('#test').attr('class', 'bam');
|
|
|
|
|
expect(doc.find('div').attr('class')).toEqual('bam');
|
|
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should get val', function() {
|
|
|
|
|
doc.append('<input value="bar">');
|
|
|
|
|
$root.dsl.element('input').val();
|
|
|
|
|
expect($root.futureResult).toEqual('bar');
|
|
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should set val', function() {
|
|
|
|
|
doc.append('<input value="bar">');
|
|
|
|
|
$root.dsl.element('input').val('baz');
|
|
|
|
|
expect(doc.find('input').val()).toEqual('baz');
|
|
|
|
|
});
|
|
|
|
|
|
2010-11-01 23:51:15 +00:00
|
|
|
it('should use correct future name for generated set methods', function() {
|
|
|
|
|
doc.append('<input value="bar">');
|
|
|
|
|
$root.dsl.element('input').val(false);
|
|
|
|
|
expect($root.futures.pop()).toMatch(/element 'input' set val/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should use correct future name for generated get methods', function() {
|
|
|
|
|
doc.append('<input value="bar">');
|
|
|
|
|
$root.dsl.element('input').val();
|
|
|
|
|
expect($root.futures.pop()).toMatch(/element 'input' val/);
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-29 19:19:22 +00:00
|
|
|
it('should add all jQuery property methods', function() {
|
|
|
|
|
var METHODS = [
|
|
|
|
|
'val', 'text', 'html', 'height', 'innerHeight', 'outerHeight', 'width',
|
|
|
|
|
'innerWidth', 'outerWidth', 'position', 'scrollLeft', 'scrollTop', 'offset'
|
|
|
|
|
];
|
|
|
|
|
var chain = $root.dsl.element('input');
|
|
|
|
|
angular.foreach(METHODS, function(name) {
|
|
|
|
|
expect(angular.isFunction(chain[name])).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
it('should execute custom query', function() {
|
2010-10-21 06:17:59 +00:00
|
|
|
doc.append('<a id="test" href="http://example.com/myUrl"></a>');
|
2010-10-19 20:17:49 +00:00
|
|
|
$root.dsl.element('#test').query(function(elements, done) {
|
|
|
|
|
done(null, elements.attr('href'));
|
|
|
|
|
});
|
2010-10-21 06:17:59 +00:00
|
|
|
expect($root.futureResult).toEqual('http://example.com/myUrl');
|
2010-10-19 20:17:49 +00:00
|
|
|
});
|
2010-10-27 18:29:51 +00:00
|
|
|
|
|
|
|
|
it('should use the selector as label if none is given', function() {
|
|
|
|
|
$root.dsl.element('mySelector');
|
2010-11-01 23:51:15 +00:00
|
|
|
expect($root.label).toEqual('mySelector');
|
2010-10-27 18:29:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should include the selector in paren when a label is given', function() {
|
|
|
|
|
$root.dsl.element('mySelector', 'myLabel');
|
|
|
|
|
expect($root.label).toEqual('myLabel ( mySelector )');
|
|
|
|
|
});
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Repeater', function() {
|
|
|
|
|
var chain;
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
doc.append(
|
|
|
|
|
'<ul>' +
|
|
|
|
|
' <li ng:repeat-index="0"><span ng:bind="name">misko</span><span ng:bind="gender">male</span></li>' +
|
|
|
|
|
' <li ng:repeat-index="1"><span ng:bind="name">felisa</span><span ng:bind="gender">female</span></li>' +
|
|
|
|
|
'</ul>'
|
|
|
|
|
);
|
|
|
|
|
chain = $root.dsl.repeater('ul li');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should get the row count', function() {
|
|
|
|
|
chain.count();
|
|
|
|
|
expect($root.futureResult).toEqual(2);
|
|
|
|
|
});
|
|
|
|
|
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
it('should return 0 if repeater doesnt match', function() {
|
|
|
|
|
doc.find('ul').html('');
|
|
|
|
|
chain.count();
|
|
|
|
|
expect($root.futureResult).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should get a row of bindings', function() {
|
|
|
|
|
chain.row(1);
|
|
|
|
|
expect($root.futureResult).toEqual(['felisa', 'female']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should get a column of bindings', function() {
|
|
|
|
|
chain.column('gender');
|
|
|
|
|
expect($root.futureResult).toEqual(['male', 'female']);
|
|
|
|
|
});
|
2010-10-27 18:29:51 +00:00
|
|
|
|
|
|
|
|
it('should use the selector as label if none is given', function() {
|
2010-11-01 23:51:15 +00:00
|
|
|
expect($root.label).toEqual('ul li');
|
2010-10-27 18:29:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should include the selector in paren when a label is given', function() {
|
|
|
|
|
$root.dsl.repeater('mySelector', 'myLabel');
|
|
|
|
|
expect($root.label).toEqual('myLabel ( ul li mySelector )');
|
|
|
|
|
});
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
describe('Binding', function() {
|
|
|
|
|
it('should select binding by name', function() {
|
2010-10-27 05:02:24 +00:00
|
|
|
doc.append('<span class="ng-binding" ng:bind="foo.bar">some value</span>');
|
2010-10-18 21:02:18 +00:00
|
|
|
$root.dsl.binding('foo.bar');
|
2010-10-08 23:43:40 +00:00
|
|
|
expect($root.futureResult).toEqual('some value');
|
|
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should select binding in template by name', function() {
|
2010-10-27 05:02:24 +00:00
|
|
|
doc.append('<pre class="ng-binding" ng:bind-template="foo {{bar}} baz">foo some baz</pre>');
|
2010-10-18 21:02:18 +00:00
|
|
|
$root.dsl.binding('bar');
|
|
|
|
|
expect($root.futureResult).toEqual('foo some baz');
|
|
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-28 00:56:44 +00:00
|
|
|
it('should match bindings by substring match', function() {
|
|
|
|
|
doc.append('<pre class="ng-binding" ng:bind="foo.bar() && test.baz() | filter">binding value</pre>');
|
|
|
|
|
$root.dsl.binding('test.baz');
|
|
|
|
|
expect($root.futureResult).toEqual('binding value');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return error if no bindings in document', function() {
|
|
|
|
|
$root.dsl.binding('foo.bar');
|
|
|
|
|
expect($root.futureError).toMatch(/did not match/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return error if no binding matches', function() {
|
|
|
|
|
doc.append('<span class="ng-binding" ng:bind="foo">some value</span>');
|
2010-10-18 21:02:18 +00:00
|
|
|
$root.dsl.binding('foo.bar');
|
|
|
|
|
expect($root.futureError).toMatch(/did not match/);
|
|
|
|
|
});
|
|
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
describe('Using', function() {
|
|
|
|
|
it('should prefix selector in $document.elements()', function() {
|
|
|
|
|
var chain;
|
|
|
|
|
doc.append(
|
|
|
|
|
'<div id="test1"><input name="test.input" value="something"></div>' +
|
|
|
|
|
'<div id="test2"><input name="test.input" value="something"></div>'
|
|
|
|
|
);
|
|
|
|
|
chain = $root.dsl.using('div#test2');
|
|
|
|
|
chain.input('test.input').enter('foo');
|
|
|
|
|
var inputs = _jQuery('input[name="test.input"]');
|
|
|
|
|
expect(inputs.first().val()).toEqual('something');
|
|
|
|
|
expect(inputs.last().val()).toEqual('foo');
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-10-27 18:29:51 +00:00
|
|
|
|
|
|
|
|
it('should use the selector as label if none is given', function() {
|
|
|
|
|
$root.dsl.using('mySelector');
|
2010-11-01 23:51:15 +00:00
|
|
|
expect($root.label).toEqual('mySelector');
|
2010-10-27 18:29:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should include the selector in paren when a label is given', function() {
|
|
|
|
|
$root.dsl.using('mySelector', 'myLabel');
|
|
|
|
|
expect($root.label).toEqual('myLabel ( mySelector )');
|
|
|
|
|
});
|
|
|
|
|
|
2010-08-13 19:05:50 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
describe('Input', function() {
|
|
|
|
|
it('should change value in text input', function() {
|
|
|
|
|
doc.append('<input name="test.input" value="something">');
|
2010-10-18 21:02:18 +00:00
|
|
|
var chain = $root.dsl.input('test.input');
|
2010-10-08 23:43:40 +00:00
|
|
|
chain.enter('foo');
|
|
|
|
|
expect(_jQuery('input[name="test.input"]').val()).toEqual('foo');
|
|
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
it('should return error if no input exists', function() {
|
2010-10-18 21:02:18 +00:00
|
|
|
var chain = $root.dsl.input('test.input');
|
2010-10-08 23:43:40 +00:00
|
|
|
chain.enter('foo');
|
2010-10-18 21:02:18 +00:00
|
|
|
expect($root.futureError).toMatch(/did not match/);
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
it('should toggle checkbox state', function() {
|
|
|
|
|
doc.append('<input type="checkbox" name="test.input" checked>');
|
2010-10-15 20:44:53 +00:00
|
|
|
expect(_jQuery('input[name="test.input"]').
|
|
|
|
|
attr('checked')).toBeTruthy();
|
2010-10-18 21:02:18 +00:00
|
|
|
var chain = $root.dsl.input('test.input');
|
2010-10-08 23:43:40 +00:00
|
|
|
chain.check();
|
2010-10-15 20:44:53 +00:00
|
|
|
expect(_jQuery('input[name="test.input"]').
|
|
|
|
|
attr('checked')).toBeFalsy();
|
2010-10-08 23:43:40 +00:00
|
|
|
$window.angular.reset();
|
|
|
|
|
chain.check();
|
2010-10-15 20:44:53 +00:00
|
|
|
expect(_jQuery('input[name="test.input"]').
|
|
|
|
|
attr('checked')).toBeTruthy();
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should return error if checkbox did not match', function() {
|
|
|
|
|
var chain = $root.dsl.input('test.input');
|
2010-10-08 23:43:40 +00:00
|
|
|
chain.check();
|
2010-10-18 21:02:18 +00:00
|
|
|
expect($root.futureError).toMatch(/did not match/);
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should select option from radio group', function() {
|
|
|
|
|
doc.append(
|
|
|
|
|
'<input type="radio" name="0@test.input" value="foo">' +
|
2010-10-18 21:02:18 +00:00
|
|
|
'<input type="radio" name="0@test.input" value="bar" checked="checked">'
|
|
|
|
|
);
|
2010-10-15 20:44:53 +00:00
|
|
|
// HACK! We don't know why this is sometimes false on chrome
|
|
|
|
|
_jQuery('input[name="0@test.input"][value="bar"]').attr('checked', true);
|
|
|
|
|
expect(_jQuery('input[name="0@test.input"][value="bar"]').
|
|
|
|
|
attr('checked')).toBeTruthy();
|
|
|
|
|
expect(_jQuery('input[name="0@test.input"][value="foo"]').
|
|
|
|
|
attr('checked')).toBeFalsy();
|
2010-10-18 21:02:18 +00:00
|
|
|
var chain = $root.dsl.input('test.input');
|
2010-10-08 23:43:40 +00:00
|
|
|
chain.select('foo');
|
2010-10-15 20:44:53 +00:00
|
|
|
expect(_jQuery('input[name="0@test.input"][value="bar"]').
|
|
|
|
|
attr('checked')).toBeFalsy();
|
|
|
|
|
expect(_jQuery('input[name="0@test.input"][value="foo"]').
|
|
|
|
|
attr('checked')).toBeTruthy();
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-10-15 20:44:53 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
it('should return error if radio button did not match', function() {
|
|
|
|
|
var chain = $root.dsl.input('test.input');
|
2010-10-08 23:43:40 +00:00
|
|
|
chain.select('foo');
|
2010-10-18 21:02:18 +00:00
|
|
|
expect($root.futureError).toMatch(/did not match/);
|
2010-10-08 23:43:40 +00:00
|
|
|
});
|
2010-08-10 00:55:01 +00:00
|
|
|
});
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-08-10 00:55:01 +00:00
|
|
|
});
|
2010-06-09 19:35:40 +00:00
|
|
|
});
|