Date asserter.
Assert that the actual
value is an instance of Date
(using .isDate()
assertion).
The date()
asserter provides adapted assertions for works on a Date
instance.
See also the spec of "date" asserter for more examples.
Example
test.date(actual);
Methods
-
is(expected)
-
Assert
actual
Date
equality by content and if possible, recursively.Also handles circular and self-referential objects.
For most parts it asserts strict equality (
===
), but:Date
objects are compared by their value.- Instances of the same class with a
valueOf
function are compared by its output. - Plain objects and instances of the same class are compared recursively.
Does not coerce types so mismatching types fail. Inherited enumerable properties are also taken into account.
ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(date).is(new Date('2010, 5, 20'));
See also -
isNot(expected)
-
Assert
actual
Date
to the negative equality by content and if possible, recursively.Also handles circular and self-referential objects.
For most parts it asserts strict (
!==
), but:Date
objects are compared by their value.- Instances of the same class with a
valueOf
function are compared by its output. - Plain objects and instances of the same class are compared recursively.
Does not coerce types so mismatching types fail. Inherited enumerable properties are also taken into account.
ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(date).isNot(new Date('2012, 02, 28'));
See also -
isIdenticalTo(expected)
-
Assert that the
actual
Date
is identical to (===
)expected
date.ParametersName Type Description expected mixedExpected date
ReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); var ref = date; test.date(ref).isIdenticalTo(date);
See also -
isNotIdenticalTo(expected)
-
Assert that the
actual
Date
is not identical to (!==
)expected
date.ParametersName Type Description expected mixedExpected date
ReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(date).isNotIdenticalTo(new Date('2010, 5, 20'));
See also -
isEqualTo(expected)
-
Assert that the
actual
Date
is equal to (==
) theexpected
date.ParametersName Type Description expected mixedExpected date
ReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); var ref = date; test.date(ref).isEqualTo(date);
See also -
isNotEqualTo(expected)
-
Assert that the
actual
Date
is not equal to (!=
) theexpected
date.ParametersName Type Description expected mixedExpected date
ReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(new Date('2010, 5, 20')).isNotEqualTo(date);
See also -
match(expected)
-
Assert
actual
Date
to match theexpected
value.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).match(/2010/);
See also -
notMatch(expected)
-
Assert
actual
Date
to not match theexpected
value.ParametersName Type Description expected StringNumberRegExpfunctionExpected value that must not match
ReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).notMatch(/2012/);
See also -
isValid(expected)
-
Alias of
match()
.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).isValid(/2010/);
See also -
isNotValid(expected)
-
Alias of
notMatch()
.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).isNotValid(/2012/);
See also -
isBetween(begin, end)
-
Assert that the
actual
Date
is betweenbegin
andend
(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')) .isBetween(new Date('1982, 02, 17'), new Date('2012, 02, 28'));
See also -
isNotBetween(begin, end)
-
Assert that the
actual
Date
is not betweenbegin
andend
(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')) .isNotBetween(new Date('2011, 02, 17'), new Date('2012, 02, 28'));
See also -
isBefore(expected)
-
Assert that the
actual
Date
is before theexpected
value.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.date(new Date(2010, 5, 20)).isBefore(new Date(2012, 2, 28));
See also -
isAfter(expected)
-
Assert that the
actual
Date
is after theexpected
value.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.date(new Date(2012, 2, 28)).isAfter(new Date(2010, 5, 20));
See also