date() behavior
Does not contains assertions from the assertions containers.
test
.value(test.date(new Date()).hasHeader)
.isUndefined()
.value(test.date(new Date()).hasProperty)
.isUndefined()
.value(test.date(new Date()).hasMessage)
.isUndefined()
.value(test.date(new Date()).isInfinite)
.isUndefined()
;
Assert that the tested value is an instance of Date
.
test
.date(new Date())
.date(new Date('2010, 5, 20'))
.case('Test failure', function(){
test
.exception(function(){
test.date('2010 5 20');
})
.exception(function(){
test.date(2010);
})
.exception(function(){
test.date(Date);
})
;
})
;
Assertions of date()
is(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.is(new Date('2010, 5, 20'))
.case('Test failure', function(){
test
.exception(function(){
test.date(date).is(/2010/);
})
.exception(function(){
test.date(date).is(new Date('2011, 5, 20'));
})
;
})
;
isNot(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isNot(new Date('2012, 02, 28'))
.case('Test failure', function(){
test
.exception(function(){
test.date(date).isNot(new Date('2010, 5, 20'));
})
.exception(function(){
test.date(date).isNot(date);
})
;
})
;
isIdenticalTo(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isIdenticalTo(date)
.exception(function(){
test.date(date).isIdenticalTo(new Date('2010, 5, 20'));
})
;
isNotIdenticalTo(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isNotIdenticalTo(new Date('2010, 5, 20'))
.exception(function(){
test.date(date).isNotIdenticalTo(date);
})
;
isEqualTo(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isEqualTo(date)
.exception(function(){
test.date(date).isEqualTo(new Date('2010, 5, 20'));
})
;
isNotEqualTo(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isNotEqualTo(new Date('2010, 5, 20'))
.exception(function(){
test.date(date).isNotEqualTo(date);
})
;
match(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.match(/2010/)
.exception(function(){
test.date(date).match(/03/);
})
;
notMatch(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.notMatch(/03/)
.exception(function(){
test.date(date).notMatch(/02/);
})
;
isValid(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isValid(/2010/)
.exception(function(){
test.date(date).isValid(/03/);
})
;
isNotValid(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isNotValid(/03/)
.exception(function(){
test.date(date).isNotValid(/02/);
})
;
isBetween(begin, end).
var date = new Date('2010, 5, 20');
test
.date(date)
.isBetween(new Date('1982, 02, 17'), new Date('2012, 02, 28'))
.exception(function(){
test.date(date).isBetween(
new Date('2012, 02, 28'), new Date('1982, 02, 17')
);
})
;
isNotBetween(begin, end).
var date = new Date('2010, 5, 20');
test
.date(date)
.isNotBetween(new Date('2011, 02, 17'), new Date('2012, 02, 28'))
.exception(function(){
test.date(date).isNotBetween(
new Date('1982, 02, 17'), new Date('2012, 02, 28')
);
})
;
isBefore(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isBefore(new Date('2012, 02, 28'))
.exception(function(){
test.date(date).isBefore(new Date('1982, 02, 17'));
})
;
isAfter(expected).
var date = new Date('2010, 5, 20');
test
.date(date)
.isAfter(new Date('1982, 02, 17'))
.exception(function(){
test.date(date).isAfter(new Date('2012, 02, 28'));
})
;