@@ -24,6 +24,13 @@ test('empty value', 1, function () {
2424 equal ( $ . cookie ( 'c' ) , '' , 'should return value' ) ;
2525} ) ;
2626
27+ test ( 'simple value with expires' , 1 , function ( ) {
28+ var tomorrow = new Date ( ) ;
29+ tomorrow . setDate ( tomorrow . getDate ( ) + 5 ) ;
30+ document . cookie = 'c=testcookie; expires=' + tomorrow . toUTCString ( ) ;
31+ equal ( $ . cookie ( 'c' ) , 'testcookie' , 'should return value' ) ;
32+ } ) ;
33+
2734test ( 'not existing' , 1 , function ( ) {
2835 equal ( $ . cookie ( 'whatever' ) , null , 'should return null' ) ;
2936} ) ;
@@ -77,6 +84,19 @@ test('number', 1, function () {
7784 equal ( $ . cookie ( 'c' ) , '1234' , 'should write value' ) ;
7885} ) ;
7986
87+ test ( 'with expires 7 days from now' , 1 , function ( ) {
88+ var seven_days_from_now = new Date ( ) ;
89+ seven_days_from_now . setDate ( seven_days_from_now . getDate ( ) + 7 ) ;
90+ equal ( $ . cookie ( 'c' , 'v' , { expires :7 } ) , 'c=v; expires=' + seven_days_from_now . toUTCString ( ) , 'should return the cookie string with expires' ) ;
91+ } ) ;
92+
93+ test ( 'with expires yesterday' , 2 , function ( ) {
94+ var yesterday = new Date ( ) ;
95+ yesterday . setDate ( yesterday . getDate ( ) - 1 ) ;
96+ equal ( $ . cookie ( 'c' , 'v' , { expires :- 1 } ) , 'c=v; expires=' + yesterday . toUTCString ( ) , 'should return the cookie string with expires' ) ;
97+ equal ( document . cookie , '' , 'should not save expired cookie' ) ;
98+ } ) ;
99+
80100test ( 'return value' , 1 , function ( ) {
81101 equal ( $ . cookie ( 'c' , 'v' ) , 'c=v' , 'should return written cookie string' ) ;
82102} ) ;
0 commit comments