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
a3e8620a
...
a3e8620ab998d6963ae753059e23d1db8c2d3bde
authored
2011-12-23 15:34:13 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added tests for utils' fillBlanks()
1 parent
7d23991a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
37 deletions
tests/suites/utils.js
tests/suites/utils.js
View file @
a3e8620
(
function
(
t
)
{
t
.
comment
(
'fileExt()'
);
var
testCases
=
{
'foo.ext'
:
'ext'
,
'FOO.EXT'
:
'ext'
,
'a.ext'
:
'ext'
,
'.ext'
:
'ext'
,
'toto.'
:
''
,
' plop.ext '
:
'ext'
};
for
(
var
testCase
in
testCases
)
{
t
.
assertEquals
(
fileExt
(
testCase
),
testCases
[
testCase
],
'fileExt() extract file extension'
);
}
(
function
()
{
var
testCases
=
{
'foo.ext'
:
'ext'
,
'FOO.EXT'
:
'ext'
,
'a.ext'
:
'ext'
,
'.ext'
:
'ext'
,
'toto.'
:
''
,
' plop.ext '
:
'ext'
};
for
(
var
testCase
in
testCases
)
{
t
.
assertEquals
(
fileExt
(
testCase
),
testCases
[
testCase
],
'fileExt() extract file extension'
);
}
})();
t
.
comment
(
'fillBlanks()'
);
(
function
()
{
testCases
=
{
'foo'
:
'foo '
,
' foo bar '
:
' foo bar '
,
' foo bar '
:
' foo bar '
};
for
(
var
testCase
in
testCases
)
{
t
.
assertEquals
(
fillBlanks
(
testCase
,
10
),
testCases
[
testCase
],
'fillBlanks() fills blanks'
);
}
})();
t
.
comment
(
'mergeObjects()'
);
testCases
=
[
{
obj1
:
{
a
:
1
},
obj2
:
{
b
:
2
},
merged
:
{
a
:
1
,
b
:
2
}
},
{
obj1
:
{},
obj2
:
{
a
:
1
},
merged
:
{
a
:
1
}
},
{
obj1
:
{
a
:
1
},
obj2
:
{},
merged
:
{
a
:
1
}
},
{
obj1
:
{
a
:
1
},
obj2
:
{
a
:
2
},
merged
:
{
a
:
2
}
},
{
obj1
:
{
x
:
0
,
double
:
function
(){
return
this
.
x
*
2
;}},
obj2
:
{
triple
:
function
(){
return
this
.
x
*
3
;}},
merged
:
{
x
:
0
,
double
:
function
(){
return
this
.
x
*
2
;},
triple
:
function
(){
return
this
.
x
*
3
;}
(
function
()
{
testCases
=
[
{
obj1
:
{
a
:
1
},
obj2
:
{
b
:
2
},
merged
:
{
a
:
1
,
b
:
2
}
},
{
obj1
:
{},
obj2
:
{
a
:
1
},
merged
:
{
a
:
1
}
},
{
obj1
:
{
a
:
1
},
obj2
:
{},
merged
:
{
a
:
1
}
},
{
obj1
:
{
a
:
1
},
obj2
:
{
a
:
2
},
merged
:
{
a
:
2
}
},
{
obj1
:
{
x
:
0
,
double
:
function
(){
return
this
.
x
*
2
;}},
obj2
:
{
triple
:
function
(){
return
this
.
x
*
3
;}},
merged
:
{
x
:
0
,
double
:
function
(){
return
this
.
x
*
2
;},
triple
:
function
(){
return
this
.
x
*
3
;}
}
}
}
];
];
testCases
.
forEach
(
function
(
testCase
)
{
t
.
assertEquals
(
mergeObjects
(
testCase
.
obj1
,
testCase
.
obj2
),
testCase
.
merged
,
'mergeObjects() can merge objects'
);
});
testCases
.
forEach
(
function
(
testCase
)
{
t
.
assertEquals
(
mergeObjects
(
testCase
.
obj1
,
testCase
.
obj2
),
testCase
.
merged
,
'mergeObjects() can merge objects'
);
});
})();
t
.
done
();
})(
casper
.
test
);
...
...
Please
register
or
sign in
to post a comment