Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Remove enclosing curly braces from features and widgets #91

Merged
merged 2 commits into from
Sep 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc
Submodule doc updated from d0f030 to 1d4b4e
14 changes: 6 additions & 8 deletions example/CheckMyTrip/1 - DialingCodesFeature.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
description: 'A user should be able to look up ' + dialCodeLookupCountry + '’s dialcode',
description: 'A user should be able to look up ' + dialCodeLookupCountry + '’s dialcode',

scenario: [
TripToolsWidget.open(),
DialCodeWidget.lookup(dialCodeLookupCountry),
{ 'DialCodeWidget.result': dialCodeExpectedResult }
]
}
scenario: [
TripToolsWidget.open(),
DialCodeWidget.lookup(dialCodeLookupCountry),
{ 'DialCodeWidget.result': dialCodeExpectedResult }
]
34 changes: 16 additions & 18 deletions example/CheckMyTrip/2 - ClockFeature.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
description: 'A user should be able to look up ' + clockLookupTown + '’s local time',
description: 'A user should be able to look up ' + clockLookupTown + '’s local time',

scenario: [
function storeCurrentTime() {
return ClockWidget.getCurrentHour()()
.then(function(hour) {
storage.previousHour = hour;
});
},
ClockWidget.lookup(clockLookupTown),
function hasExpectedTimeDiff() {
return ClockWidget.getCurrentHour()()
.then(function(hour) {
assert.equal(hour, storage.previousHour - 1);
});
}
]
}
scenario: [
function storeCurrentTime() {
return ClockWidget.getCurrentHour()()
.then(function(hour) {
storage.previousHour = hour;
});
},
ClockWidget.lookup(clockLookupTown),
function hasExpectedTimeDiff() {
return ClockWidget.getCurrentHour()()
.then(function(hour) {
assert.equal(hour, storage.previousHour - 1);
});
}
]
18 changes: 8 additions & 10 deletions example/CheckMyTrip/3 - RegisterFeature.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
description: 'A user should be able to request an account',
description: 'A user should be able to request an account',

scenario: [
RegisterWidget.register(firstName, lastName),
{
'RegisterWidget.firstName' : firstName,
'RegisterWidget.lastName' : lastName
}
]
}
scenario: [
RegisterWidget.register(firstName, lastName),
{
'RegisterWidget.firstName' : firstName,
'RegisterWidget.lastName' : lastName
}
]
40 changes: 19 additions & 21 deletions example/CheckMyTrip/ClockWidget.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
{
elements: {
field : { css: '#clock input[type=text]' },
submitButton : { css: '#clock input[type=submit]' },
result : { css: '#clock .time-holder .time' },
selectAutocompleteResultButton : { css: '.xLISTItem_dropdown' }
},
elements: {
field : { css: '#clock input[type=text]' },
submitButton : { css: '#clock input[type=submit]' },
result : { css: '#clock .time-holder .time' },
selectAutocompleteResultButton : { css: '.xLISTItem_dropdown' }
},

lookup: function lookup(town) {
return this.setField(town)() // immediate execution to start the chain
.delay(800)
.then(this.setField('\ue015')) // down arrow
.then(this.submit());
},
lookup: function lookup(town) {
return this.setField(town)() // immediate execution to start the chain
.delay(800)
.then(this.setField('\ue015')) // down arrow
.then(this.submit());
},

getCurrentHour: function getCurrentHour() {
return this.result.then(function(resultElement) {
return resultElement.text();
}).then(function(text) {
var hour = text.split(':')[0]; // get the hour only
return +hour; // coerce the hour into a Number
});
}
getCurrentHour: function getCurrentHour() {
return this.result.then(function(resultElement) {
return resultElement.text();
}).then(function(text) {
var hour = text.split(':')[0]; // get the hour only
return +hour; // coerce the hour into a Number
});
}
18 changes: 8 additions & 10 deletions example/CheckMyTrip/DialCodeWidget.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
elements: {
selector : { css: '#dialingCode input[type=text]' },
submitButton : { css: '#dialingCode input[type=submit]' },
result : { css: '#dialingCode .result-wrapper .main' },
},
elements: {
selector : { css: '#dialingCode input[type=text]' },
submitButton : { css: '#dialingCode input[type=submit]' },
result : { css: '#dialingCode .result-wrapper .main' },
},

lookup: function lookup(country) {
return this.setSelector(country)() // immediate execution to start the chain
.then(this.submit());
}
lookup: function lookup(country) {
return this.setSelector(country)() // immediate execution to start the chain
.then(this.submit());
}
20 changes: 9 additions & 11 deletions example/CheckMyTrip/RegisterWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
elements: {
firstName : { css: '#register #register_firstName' },
lastName : { css: '#register #register_lastName' },
submitButton: { css: '#register input[type=submit]'}
},
elements: {
firstName : { css: '#register #register_firstName' },
lastName : { css: '#register #register_lastName' },
submitButton: { css: '#register input[type=submit]'}
},

register: function(first, last) {
return this.setFirstName(first)()
.then(this.setLastName(last))
.then(this.submit());
}
register: function(first, last) {
return this.setFirstName(first)()
.then(this.setLastName(last))
.then(this.submit());
}
8 changes: 3 additions & 5 deletions example/CheckMyTrip/TripToolsWidget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
elements: {
openLink : { css: 'em.icon.triptools' },
toolsWrapper: { css: '.triptools-controls' }
}
elements: {
openLink : { css: 'em.icon.triptools' },
toolsWrapper: { css: '.triptools-controls' }
}
10 changes: 4 additions & 6 deletions example/DuckDuckGo - advanced matchers/1 - SearchFeature.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
description: 'Look up an ambiguous term',
description: 'Look up an ambiguous term',

scenario: [
SearchBarWidget.searchFor(lookupTerm)
]
}
scenario: [
SearchBarWidget.searchFor(lookupTerm)
]
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
description: 'Make sure the Zero Click Info box exists with booleans',
description: 'Make sure the Zero Click Info box exists with booleans',

scenario: [
{
'ZeroClickWidget.header': true // prove that the element exists
}
]
}
scenario: [
{
'ZeroClickWidget.header': true // prove that the element exists
}
]
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
description: 'Match the Zero Click Info box header with RegExps',
description: 'Match the Zero Click Info box header with RegExps',

scenario: [
{
'ZeroClickWidget.header': /Meanings of/, // match the textual content with a static regexp…
'ZeroClickWidget.header': new RegExp(lookupTerm + '$') // …or with a dynamic one
}
]
}
scenario: [
{
'ZeroClickWidget.header': /Meanings of/, // match the textual content with a static regexp…
'ZeroClickWidget.header': new RegExp(lookupTerm + '$') // …or with a dynamic one
}
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
description: 'Check an HTML attribute on an element with custom matcher functions',
description: 'Check an HTML attribute on an element with custom matcher functions',

scenario: [
{
'ZeroClickWidget.header': function isAlwaysValid(header) { // providing a good name (i.e. prefixed with `is`) for the function will allow for better reports
assert.ok(true, 'This is always valid'); // you can do whatever you please in a function; if it throws, it will be considered a failure
// Node's [assert](http://nodejs.org/api/assert.html) default library is injected, so you can use it instead of `throw`ing yourself
},
'SearchBarWidget.field': function hasNoAutocompletion(searchField) { // custom matchers are always passed a WD reference to the element they evaluate; see API for such objects at <https://github.com/admc/wd#supported-methods>
return searchField.getAttribute('autocomplete') // notice that if you're using a promise, you should **always** `return` from it
.then(function(attribute) { // a promise-returning matcher will be evaluated based on whether it was resolved or rejected
assert.equal(attribute, 'off', 'Expected autocompletion to be off');
});
}
scenario: [
{
'ZeroClickWidget.header': function isAlwaysValid(header) { // providing a good name (i.e. prefixed with `is`) for the function will allow for better reports
assert.ok(true, 'This is always valid'); // you can do whatever you please in a function; if it throws, it will be considered a failure
// Node's [assert](http://nodejs.org/api/assert.html) default library is injected, so you can use it instead of `throw`ing yourself
},
'SearchBarWidget.field': function hasNoAutocompletion(searchField) { // custom matchers are always passed a WD reference to the element they evaluate; see API for such objects at <https://github.com/admc/wd#supported-methods>
return searchField.getAttribute('autocomplete') // notice that if you're using a promise, you should **always** `return` from it
.then(function(attribute) { // a promise-returning matcher will be evaluated based on whether it was resolved or rejected
assert.equal(attribute, 'off', 'Expected autocompletion to be off');
});
}
]
}
}
]
16 changes: 7 additions & 9 deletions example/DuckDuckGo - advanced matchers/SearchBarWidget.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
elements: {
field: { name: 'q' },
submitButton: { id: 'search_button_homepage' }
},
elements: {
field: { name: 'q' },
submitButton: { id: 'search_button_homepage' }
},

searchFor: function searchFor(term) {
return this.setField(term)()
.then(this.submit());
}
searchFor: function searchFor(term) {
return this.setField(term)()
.then(this.submit());
}
6 changes: 2 additions & 4 deletions example/DuckDuckGo - advanced matchers/ZeroClickWidget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
elements: {
header: { id: 'zero_click_heading' }
}
elements: {
header: { id: 'zero_click_heading' }
}
12 changes: 5 additions & 7 deletions example/DuckDuckGo/1 - ZeroClickFeature.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
description: 'Looking up an ambiguous term should make a Zero Click Info box appear.',
description: 'Looking up an ambiguous term should make a Zero Click Info box appear.',

scenario: [
SearchBarWidget.searchFor(lookupTerm),
{ 'ZeroClickWidget.header': 'Meanings of ' + lookupTerm }
]
}
scenario: [
SearchBarWidget.searchFor(lookupTerm),
{ 'ZeroClickWidget.header': 'Meanings of ' + lookupTerm }
]
16 changes: 7 additions & 9 deletions example/DuckDuckGo/SearchBarWidget.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
elements: {
field: { name: 'q' },
submitButton: { id: 'search_button_homepage' }
},
elements: {
field: { name: 'q' },
submitButton: { id: 'search_button_homepage' }
},

searchFor: function searchFor(term) {
return this.setField(term)()
.then(this.submit());
}
searchFor: function searchFor(term) {
return this.setField(term)()
.then(this.submit());
}
6 changes: 2 additions & 4 deletions example/DuckDuckGo/ZeroClickWidget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
elements: {
header: { id: 'zero_click_heading' }
}
elements: {
header: { id: 'zero_click_heading' }
}
14 changes: 6 additions & 8 deletions example/PDC/1 - LoginFeature.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
description: 'A user should be able to log in',
description: 'A user should be able to log in',

scenario: [
LoginWidget.open(),
LoginWidget.login(email, password),
scenario: [
LoginWidget.open(),
LoginWidget.login(email, password),

{ 'ToolbarWidget.username': oldName }
]
}
{ 'ToolbarWidget.username': oldName }
]
20 changes: 9 additions & 11 deletions example/PDC/2 - ChangeNameFeature.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
description: 'A user should be able to change his name',
description: 'A user should be able to change his name',

scenario: [
ToolbarWidget.editUser(),
{ 'ToolbarWidget.username': oldName },
NameEditorWidget.setUsername(newName),
{ 'ToolbarWidget.username': newName },
NameEditorWidget.setUsername(oldName),
{ 'ToolbarWidget.username': oldName }
]
}
scenario: [
ToolbarWidget.editUser(),
{ 'ToolbarWidget.username': oldName },
NameEditorWidget.setUsername(newName),
{ 'ToolbarWidget.username': newName },
NameEditorWidget.setUsername(oldName),
{ 'ToolbarWidget.username': oldName }
]
12 changes: 5 additions & 7 deletions example/PDC/3 - LogoutFeature.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
description: 'A user should be able to log out',
description: 'A user should be able to log out',

scenario: [
ToolbarWidget.logout(),
{ 'LoginWidget.openLink': true }
]
}
scenario: [
ToolbarWidget.logout(),
{ 'LoginWidget.openLink': true }
]
18 changes: 8 additions & 10 deletions example/PDC/4 - RequestPasswordFeature.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
description: 'A password reset request should be protected by a captcha',
description: 'A password reset request should be protected by a captcha',

scenario: [
LoginWidget.open(),
LoginWidget.requestPassword(),
{ 'PasswordRequestWidget.captcha': true },
PasswordRequestWidget.askFor(badEmail), // check that the captcha is here even after having tried to ask for a reset
{ 'PasswordRequestWidget.captcha': true }
]
}
scenario: [
LoginWidget.open(),
LoginWidget.requestPassword(),
{ 'PasswordRequestWidget.captcha': true },
PasswordRequestWidget.askFor(badEmail), // check that the captcha is here even after having tried to ask for a reset
{ 'PasswordRequestWidget.captcha': true }
]
Loading