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
ff4624e2
...
ff4624e22817dd508dded605cb76d3dce0a5838a
authored
2012-12-28 14:00:47 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
migrated casper/capture tests to new testing format
1 parent
0e70c19d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
21 deletions
tests/suites/casper/capture.js
tests/suites/casper/capture.js
View file @
ff4624e
/*global casper*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
),
testFile
=
'/tmp/__casper_test_capture.png'
;
var
fs
=
require
(
'fs'
),
testFile
=
'/tmp/__casper_test_capture.png'
;
if
(
fs
.
exists
(
testFile
)
&&
fs
.
isFile
(
testFile
))
{
fs
.
remove
(
testFile
);
}
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
viewport
(
300
,
200
);
this
.
test
.
comment
(
'Casper.capture()'
);
this
.
capture
(
testFile
);
this
.
test
.
assert
(
fs
.
isFile
(
testFile
),
'Casper.capture() captured a screenshot'
);
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
()
{
try
{
fs
.
remove
(
testFile
);
}
catch
(
e
)
{
this
.
warn
(
'Unable to delete test file '
+
testFile
+
'; please delete it manually'
);
}
test
.
done
();
});
});
casper
.
thenOpen
(
'tests/site/index.html'
,
function
()
{
this
.
test
.
comment
(
'Casper.captureBase64()'
);
this
.
test
.
assert
(
this
.
captureBase64
(
'png'
).
length
>
0
,
'Casper.captureBase64() rendered a page capture as base64'
);
this
.
test
.
assert
(
this
.
captureBase64
(
'png'
,
'ul'
).
length
>
0
,
'Casper.captureBase64() rendered a capture from a selector as base64'
);
this
.
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
.
run
(
function
()
{
try
{
fs
.
remove
(
testFile
);
}
catch
(
e
)
{}
this
.
test
.
done
(
4
);
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'
);
test
.
assert
(
this
.
captureBase64
(
'png'
,
'ul'
).
length
>
0
,
'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'
);
}).
run
(
function
()
{
test
.
done
();
});
});
...
...
Please
register
or
sign in
to post a comment