Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
939cee41
...
939cee41e064228da303669b42e46e197277d35f
authored
2013-03-10 12:52:17 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refs #405 - renamed Casper#skip to #bypass
1 parent
653867b3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
126 deletions
modules/casper.js
modules/tester.js
tests/suites/casper/bypass.js
tests/suites/casper/skip.js → tests/suites/tester/skip.js
modules/casper.js
View file @
939cee4
...
...
@@ -243,6 +243,21 @@ Casper.prototype.base64encode = function base64encode(url, method, data) {
};
/**
* Bypasses `nb` steps.
*
* @param Integer nb Number of steps to bypass
*/
Casper
.
prototype
.
bypass
=
function
bypass
(
nb
)
{
"use strict"
;
var
step
=
this
.
step
,
steps
=
this
.
steps
,
last
=
steps
.
length
;
this
.
checkStarted
();
this
.
step
=
Math
.
min
(
step
+
nb
,
last
);
return
this
;
};
/**
* Proxy method for WebPage#render. Adds a clipRect parameter for
* automatically set page clipRect setting values and sets it back once
* done. If the cliprect parameter is omitted, the full page viewport
...
...
@@ -1608,72 +1623,50 @@ Casper.prototype.thenOpen = function thenOpen(location, settings, then) {
};
/**
*
Skip
`nb` steps.
*
Adds a step which bypasses
`nb` steps.
*
* @param Integer nb number of tests to skip
* @param String message message to display
* @param Integer nb Number of steps to bypass
*/
Casper
.
prototype
.
skip
=
function
skip
(
nb
,
message
)
{
"use strict"
;
var
step
=
this
.
step
,
steps
=
this
.
steps
,
last
=
steps
.
length
;
this
.
checkStarted
();
this
.
step
=
Math
.
min
(
step
+
nb
,
last
);
return
this
;
};
/**
* Skip `nb` steps.
*
* @param Integer nb number of tests to skip
* @param String message message to display
*/
Casper
.
prototype
.
thenSkip
=
function
(
nb
,
message
)
{
return
this
.
then
(
function
()
{
this
.
skip
(
nb
,
message
);
Casper
.
prototype
.
thenBypass
=
function
thenBypass
(
nb
)
{
return
this
.
then
(
function
_thenBypass
()
{
this
.
bypass
(
nb
);
});
};
/**
*
Skip
`nb` steps if condition is true.
*
Bypass
`nb` steps if condition is true.
*
* @param Mixed condition number of tests to skip
* @param Integer nb number of tests to skip
* @param String message message to display
* @param Mixed condition Test condition
* @param Integer nb Number of steps to bypass
*/
Casper
.
prototype
.
then
SkipIf
=
function
(
condition
,
nb
,
message
)
{
return
this
.
then
(
function
()
{
Casper
.
prototype
.
then
BypassIf
=
function
thenBypassIf
(
condition
,
nb
)
{
return
this
.
then
(
function
_thenBypassIf
()
{
if
(
utils
.
isFunction
(
condition
))
{
condition
=
condition
(
);
condition
=
condition
.
call
(
this
);
}
if
(
utils
.
isTruthy
(
condition
))
{
this
.
skip
(
nb
,
message
);
this
.
bypass
(
nb
);
}
});
};
/**
*
Skip
`nb` steps if condition is true.
*
Bypass
`nb` steps if condition is true.
*
* @param Mixed condition number of tests to skip
* @param Integer nb number of tests to skip
* @param String message message to display
* @param Mixed condition Test condition
* @param Integer nb Number of tests to bypass
*/
Casper
.
prototype
.
then
SkipUnless
=
function
(
condition
,
nb
,
message
)
{
return
this
.
then
(
function
()
{
Casper
.
prototype
.
then
BypassUnless
=
function
thenBypassUnless
(
condition
,
nb
)
{
return
this
.
then
(
function
_thenBypassUnless
()
{
if
(
utils
.
isFunction
(
condition
))
{
condition
=
condition
(
);
condition
=
condition
.
call
(
this
);
}
if
(
utils
.
isFalsy
(
condition
))
{
this
.
skip
(
nb
,
message
);
this
.
bypass
(
nb
);
}
});
};
/**
* Adds a new navigation step for opening and evaluate an expression
* against the DOM retrieved from the provided location.
...
...
modules/tester.js
View file @
939cee4
...
...
@@ -236,14 +236,12 @@ Tester.prototype.abort = function abort(message) {
/**
* Skip `nb` tests.
*
* @param
Integer nb n
umber of tests to skip
* @param
String message m
essage to display
* @param
Integer nb N
umber of tests to skip
* @param
String message M
essage to display
*/
Tester
.
prototype
.
skip
=
function
skip
(
nb
,
message
)
{
"use strict"
;
this
.
casper
.
skip
(
nb
,
message
);
this
.
casper
.
bypass
(
nb
);
return
this
.
processAssertionResult
({
success
:
null
,
standard
:
f
(
"Skipping %d tests"
,
nb
),
...
...
tests/suites/casper/bypass.js
0 → 100644
View file @
939cee4
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
begin
(
'Casper.bypass() can bypass a step'
,
1
,
function
(
test
)
{
casper
.
start
();
casper
.
then
(
function
(){
test
.
fail
(
"This test should not be executed."
);
});
casper
.
bypass
(
1
).
run
(
function
()
{
test
.
pass
(
"Step has been bypassed"
);
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.bypass() can bypass multiple steps'
,
1
,
function
(
test
)
{
casper
.
start
();
casper
.
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
then
(
function
()
{
this
.
bypass
(
2
);
});
casper
.
then
(
function
()
{
test
.
fail
(
"This test should not be executed."
);
});
casper
.
then
(
function
()
{
test
.
fail
(
"Nor this one."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenBypass()'
,
1
,
function
(
test
)
{
casper
.
thenBypass
(
1
).
then
(
function
()
{
test
.
fail
(
"This test should be bypassed."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenBypassIf()'
,
3
,
function
(
test
)
{
casper
.
thenBypassIf
(
true
,
1
,
"Bypass if with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be bypassed."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenBypassIf
(
function
()
{
return
true
;
},
1
,
"Bypass if with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be bypassed."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenBypassIf
(
function
()
{
return
false
;
},
1
,
"Do not bypass if with function"
).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenBypassUnless()'
,
3
,
function
(
test
)
{
casper
.
thenBypassUnless
(
false
,
1
,
"Bypass unless with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be bypassed."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenBypassUnless
(
function
()
{
return
false
;
},
1
,
"Bypass unless with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be bypassed."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenBypassUnless
(
function
()
{
return
true
;
},
1
,
"Do not bypass unless with function"
).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
tests/suites/
casp
er/skip.js
→
tests/suites/
test
er/skip.js
View file @
939cee4
...
...
@@ -40,8 +40,7 @@ casper.test.begin('Skip multiple', 1, function(test) {
});
casper
.
test
.
begin
(
'Skip more than there is'
,
0
,
function
(
test
)
{
casper
.
then
(
function
()
{
casper
.
then
(
function
()
{
test
.
skip
(
2
);
});
...
...
@@ -51,53 +50,7 @@ casper.test.begin('Skip more than there is', 0, function(test) {
});
casper
.
test
.
begin
(
'Skip does not polluate next suite'
,
1
,
function
(
test
)
{
casper
.
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenSkip'
,
1
,
function
(
test
)
{
casper
.
thenSkip
(
1
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenSkipIf'
,
3
,
function
(
test
)
{
casper
.
thenSkipIf
(
true
,
1
,
"Skip if with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipIf
(
function
()
{
return
true
;
},
1
,
"Skip if with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipIf
(
function
()
{
return
false
;
},
1
,
"Do not skip if with function"
).
then
(
function
()
{
casper
.
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
...
...
@@ -105,34 +58,3 @@ casper.test.begin('Casper.thenSkipIf', 3, function(test) {
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenSkipUnless'
,
3
,
function
(
test
)
{
casper
.
thenSkipUnless
(
false
,
1
,
"Skip unless with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipUnless
(
function
()
{
return
false
;
},
1
,
"Skip unless with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipUnless
(
function
()
{
return
true
;
},
1
,
"Do not skip unless with function"
).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
...
...
Please
register
or
sign in
to post a comment