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
c64cd455
...
c64cd455fee549b99e53f5da6d7bc231af6c8177
authored
2013-02-25 21:10:41 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
migrated so tests to use setUp/tearDown - refs #397
1 parent
047a8091
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
39 deletions
docs
tests/suites/casper/agent.js
tests/suites/casper/alert.js
tests/suites/casper/capture.js
tests/suites/tester/.casper
docs
@
442060c4
Subproject commit
2f5e1fcd2b9812b286a7eac98df327691b7558b7
Subproject commit
442060c4b89053177962720d76e89468afd2918e
...
...
tests/suites/casper/agent.js
View file @
c64cd45
...
...
@@ -14,12 +14,19 @@ function fetchUA(request) {
testUA
(
headers
.
pop
().
value
,
/plop/
);
}
casper
.
test
.
begin
(
'userAgent() tests'
,
3
,
function
(
test
)
{
testUA
(
casper
.
options
.
pageSettings
.
userAgent
,
/CasperJS/
);
casper
.
start
();
casper
.
userAgent
(
'plop'
).
once
(
'resource.requested'
,
fetchUA
);
casper
.
thenOpen
(
'tests/site/index.html'
);
casper
.
run
(
function
()
{
test
.
done
();
});
casper
.
test
.
begin
(
'userAgent() tests'
,
3
,
{
originalUA
:
casper
.
options
.
pageSettings
.
userAgent
,
tearDown
:
function
(
test
)
{
casper
.
userAgent
(
this
.
originalUA
);
},
test
:
function
(
test
)
{
testUA
(
casper
.
options
.
pageSettings
.
userAgent
,
/CasperJS/
);
casper
.
start
().
userAgent
(
'plop'
).
once
(
'resource.requested'
,
fetchUA
);
casper
.
thenOpen
(
'tests/site/index.html'
).
run
(
function
()
{
test
.
done
();
});
}
});
...
...
tests/suites/casper/alert.js
View file @
c64cd45
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
begin
(
'alert events'
,
1
,
function
(
test
)
{
var
ok
=
false
;
casper
.
once
(
'remote.alert'
,
function
(
message
)
{
ok
=
message
===
'plop'
;
});
casper
.
start
(
'tests/site/alert.html'
,
function
()
{
test
.
assert
(
ok
,
'alert event has been intercepted'
);
});
casper
.
run
(
function
()
{
this
.
removeAllListeners
(
'remote.alert'
);
test
.
done
();
});
casper
.
test
.
begin
(
'alert events'
,
1
,
{
ok
:
false
,
tearDown
:
function
(
test
)
{
casper
.
removeAllListeners
(
'remote.alert'
);
},
test
:
function
(
test
)
{
var
self
=
this
;
casper
.
once
(
'remote.alert'
,
function
(
message
)
{
self
.
ok
=
(
message
===
'plop'
);
});
casper
.
start
(
'tests/site/alert.html'
,
function
()
{
test
.
assert
(
self
.
ok
,
'alert event has been intercepted'
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
...
...
tests/suites/casper/capture.js
View file @
c64cd45
/*global casper*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
),
testFile
=
'/tmp/__casper_test_capture.png'
;
var
fs
=
require
(
'fs'
);
if
(
fs
.
exists
(
testFile
)
&&
fs
.
isFile
(
testFile
))
{
fs
.
remove
(
testFile
);
}
casper
.
test
.
begin
(
'Casper.capture() tests'
,
1
,
{
testFile
:
'/tmp/__casper_test_capture.png'
,
casper
.
test
.
begin
(
'Casper.capture() tests'
,
1
,
function
(
test
)
{
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
viewport
(
300
,
200
);
this
.
capture
(
testFile
);
test
.
assert
(
fs
.
isFile
(
testFile
),
'Casper.capture() captured a screenshot'
);
}).
run
(
function
()
{
setUp
:
function
(
test
)
{
if
(
fs
.
exists
(
this
.
testFile
)
&&
fs
.
isFile
(
this
.
testFile
))
{
try
{
fs
.
remove
(
this
.
testFile
);
}
catch
(
e
)
{
}
}
},
tearDown
:
function
(
test
)
{
try
{
fs
.
remove
(
testFile
);
fs
.
remove
(
t
his
.
t
estFile
);
}
catch
(
e
)
{
this
.
warn
(
'Unable to delete test file '
+
testFile
+
'; please delete it manually'
);
}
test
.
done
();
});
},
test
:
function
(
test
)
{
var
self
=
this
;
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
viewport
(
300
,
200
);
this
.
capture
(
self
.
testFile
);
test
.
assert
(
fs
.
isFile
(
self
.
testFile
),
'Casper.capture() captured a screenshot'
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'Casper.captureBase64() tests'
,
3
,
function
(
test
)
{
casper
.
start
(
'tests/site/index.html'
,
function
()
{
test
.
assert
(
this
.
captureBase64
(
'png'
).
length
>
0
,
'Casper.captureBase64() rendered a page capture as base64'
);
'Casper.captureBase64() rendered a page capture as base64'
);
test
.
assert
(
this
.
captureBase64
(
'png'
,
'ul'
).
length
>
0
,
'Casper.captureBase64() rendered a capture from a selector as base64'
);
'Casper.captureBase64() rendered a capture from a selector as base64'
);
test
.
assert
(
this
.
captureBase64
(
'png'
,
{
top
:
0
,
left
:
0
,
width
:
30
,
height
:
30
}).
length
>
0
,
'Casper.captureBase64() rendered a capture from a clipRect as base64'
);
'Casper.captureBase64() rendered a capture from a clipRect as base64'
);
}).
run
(
function
()
{
test
.
done
();
});
...
...
tests/suites/tester/.casper
0 → 100644
View file @
c64cd45
File mode changed
Please
register
or
sign in
to post a comment