@@ -1254,6 +1254,179 @@ describe('datepicker directive', function() {
1254
1254
1255
1255
} ) ;
1256
1256
1257
+ describe ( 'uibDatepickerPopupConfig.timelessJsonMode = true' , function ( ) {
1258
+ var inputEl , dropdownEl , $document , $sniffer , $timeout ;
1259
+
1260
+ function assignElements ( wrapElement ) {
1261
+ inputEl = wrapElement . find ( 'input' ) ;
1262
+ dropdownEl = wrapElement . find ( 'ul' ) ;
1263
+ element = dropdownEl . find ( 'table' ) ;
1264
+ }
1265
+
1266
+ beforeEach ( inject ( function ( uibDatepickerPopupConfig ) {
1267
+ uibDatepickerPopupConfig . timelessJsonMode = true ;
1268
+ $rootScope . date = '2010-09-30T00:00:00.000' ;
1269
+ $rootScope . isopen = true ;
1270
+ var wrapper = $compile ( '<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" is-open="isopen"></div>' ) ( $rootScope ) ;
1271
+ $rootScope . $digest ( ) ;
1272
+ assignElements ( wrapper ) ;
1273
+ } ) ) ;
1274
+
1275
+ afterEach ( inject ( function ( uibDatepickerPopupConfig ) {
1276
+ // return it to the original state
1277
+ delete uibDatepickerPopupConfig . timelessJsonMode ;
1278
+ } ) ) ;
1279
+
1280
+ it ( 'formats model to yyyy-MM-dd on initialization' , function ( ) {
1281
+ expect ( inputEl . val ( ) ) . toBe ( '09/30/2010' ) ;
1282
+ expect ( $rootScope . date ) . toEqual ( '2010-09-30' ) ;
1283
+ } ) ;
1284
+
1285
+ it ( 'updates the input when a day is clicked' , function ( ) {
1286
+ clickOption ( 17 ) ;
1287
+ expect ( inputEl . val ( ) ) . toBe ( '09/15/2010' ) ;
1288
+ expect ( $rootScope . date ) . toEqual ( '2010-09-15' ) ;
1289
+ } ) ;
1290
+ } ) ;
1291
+
1292
+ describe ( 'timeless-json-mode="true"' , function ( ) {
1293
+ var inputEl , dropdownEl , $document , $sniffer , $timeout ;
1294
+
1295
+ function assignElements ( wrapElement ) {
1296
+ inputEl = wrapElement . find ( 'input' ) ;
1297
+ dropdownEl = wrapElement . find ( 'ul' ) ;
1298
+ element = dropdownEl . find ( 'table' ) ;
1299
+ }
1300
+
1301
+ beforeEach ( inject ( function ( ) {
1302
+ $rootScope . date = '2010-09-30T00:00:00.000' ;
1303
+ $rootScope . isopen = true ;
1304
+ var wrapper = $compile ( '<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" timeless-json-mode="true" is-open="isopen"></div>' ) ( $rootScope ) ;
1305
+ $rootScope . $digest ( ) ;
1306
+ assignElements ( wrapper ) ;
1307
+ } ) ) ;
1308
+
1309
+ it ( 'formats model to yyyy-MM-dd on initialization' , function ( ) {
1310
+ expect ( inputEl . val ( ) ) . toBe ( '09/30/2010' ) ;
1311
+ expect ( $rootScope . date ) . toEqual ( '2010-09-30' ) ;
1312
+ } ) ;
1313
+
1314
+ it ( 'updates the input when a day is clicked' , function ( ) {
1315
+ clickOption ( 17 ) ;
1316
+ expect ( inputEl . val ( ) ) . toBe ( '09/15/2010' ) ;
1317
+ expect ( $rootScope . date ) . toEqual ( '2010-09-15' ) ;
1318
+ } ) ;
1319
+ } ) ;
1320
+
1321
+ describe ( 'uibDatepickerPopupConfig.timelessJsonMode = true with HTML5' , function ( ) {
1322
+ var inputEl , dropdownEl , $document , $sniffer , $timeout ;
1323
+
1324
+ function assignElements ( wrapElement ) {
1325
+ inputEl = wrapElement . find ( 'input' ) ;
1326
+ dropdownEl = wrapElement . find ( 'ul' ) ;
1327
+ element = dropdownEl . find ( 'table' ) ;
1328
+ }
1329
+
1330
+ beforeEach ( inject ( function ( uibDatepickerPopupConfig ) {
1331
+ uibDatepickerPopupConfig . timelessJsonMode = true ;
1332
+ $rootScope . date = '2010-09-30T00:00:00.000' ;
1333
+ $rootScope . isopen = true ;
1334
+ var wrapper = $compile ( '<div><input type="date" ng-model="date" uib-datepicker-popup is-open="isopen"></div>' ) ( $rootScope ) ;
1335
+ $rootScope . $digest ( ) ;
1336
+ assignElements ( wrapper ) ;
1337
+ } ) ) ;
1338
+
1339
+ afterEach ( inject ( function ( uibDatepickerPopupConfig ) {
1340
+ // return it to the original state
1341
+ delete uibDatepickerPopupConfig . timelessJsonMode ;
1342
+ } ) ) ;
1343
+
1344
+ it ( 'formats model to yyyy-MM-dd on initialization' , function ( ) {
1345
+ expect ( inputEl . val ( ) ) . toBe ( '2010-09-30' ) ;
1346
+ expect ( $rootScope . date ) . toEqual ( '2010-09-30' ) ;
1347
+ } ) ;
1348
+
1349
+ it ( 'updates the input when a day is clicked' , function ( ) {
1350
+ clickOption ( 17 ) ;
1351
+ expect ( inputEl . val ( ) ) . toBe ( '2010-09-15' ) ;
1352
+ expect ( $rootScope . date ) . toEqual ( '2010-09-15' ) ;
1353
+ } ) ;
1354
+ } ) ;
1355
+
1356
+ describe ( 'jsonDateUtils service: timelessJsonUtils.jsonDateToTicks' , function ( ) {
1357
+ var inputEl , dropdownEl , $document , $sniffer , $timeout ;
1358
+
1359
+ function assignElements ( wrapElement ) {
1360
+ inputEl = wrapElement . find ( 'input' ) ;
1361
+ dropdownEl = wrapElement . find ( 'ul' ) ;
1362
+ element = dropdownEl . find ( 'table' ) ;
1363
+ }
1364
+
1365
+ beforeEach ( inject ( function ( timelessJsonUtils ) {
1366
+ $rootScope . toTicks = timelessJsonUtils . jsonDateToTicks ;
1367
+ $rootScope . date = '2010-09-15T00:00:00.000' ;
1368
+ $rootScope . isopen = true ;
1369
+ var wrapper = $compile ( '<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" timeless-json-mode="true" max-date="toTicks(date, 1)" is-open="isopen"></div>' ) ( $rootScope ) ;
1370
+ $rootScope . $digest ( ) ;
1371
+ assignElements ( wrapper ) ;
1372
+ } ) ) ;
1373
+
1374
+ it ( 'service method jsonDateUtils.jsonDateToTicks should work with max-date' , function ( ) {
1375
+ expect ( getAllOptionsEl ( ) . eq ( 19 ) . prop ( 'disabled' ) ) . toBe ( true ) ;
1376
+ } ) ;
1377
+ } ) ;
1378
+
1379
+ describe ( 'uibDatepickerPopupConfig.timelessJsonMode = "withUtils"' , function ( ) {
1380
+ var inputEl , dropdownEl , $document , $sniffer , $timeout ;
1381
+
1382
+ function assignElements ( wrapElement ) {
1383
+ inputEl = wrapElement . find ( 'input' ) ;
1384
+ dropdownEl = wrapElement . find ( 'ul' ) ;
1385
+ element = dropdownEl . find ( 'table' ) ;
1386
+ }
1387
+
1388
+ beforeEach ( inject ( function ( uibDatepickerPopupConfig ) {
1389
+ uibDatepickerPopupConfig . timelessJsonMode = 'withUtils' ;
1390
+ $rootScope . date = '2010-09-15T00:00:00.000' ;
1391
+ $rootScope . isopen = true ;
1392
+ var wrapper = $compile ( '<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" max-date="jsonDateAddDays(date, 1)" is-open="isopen"></div>' ) ( $rootScope ) ;
1393
+ $rootScope . $digest ( ) ;
1394
+ assignElements ( wrapper ) ;
1395
+ } ) ) ;
1396
+
1397
+ afterEach ( inject ( function ( uibDatepickerPopupConfig ) {
1398
+ // return it to the original state
1399
+ delete uibDatepickerPopupConfig . timelessJsonMode ;
1400
+ } ) ) ;
1401
+
1402
+
1403
+ it ( 'jsonDateToTicks/jsonDateAddDays should be on parent scope and work with max-date' , function ( ) {
1404
+ expect ( getAllOptionsEl ( ) . eq ( 19 ) . prop ( 'disabled' ) ) . toBe ( true ) ;
1405
+ } ) ;
1406
+ } ) ;
1407
+
1408
+ describe ( 'jsonDateToTicks/jsonDateAddDays with timeless-json-mode="withUtils"' , function ( ) {
1409
+ var inputEl , dropdownEl , $document , $sniffer , $timeout ;
1410
+
1411
+ function assignElements ( wrapElement ) {
1412
+ inputEl = wrapElement . find ( 'input' ) ;
1413
+ dropdownEl = wrapElement . find ( 'ul' ) ;
1414
+ element = dropdownEl . find ( 'table' ) ;
1415
+ }
1416
+
1417
+ beforeEach ( inject ( function ( ) {
1418
+ $rootScope . date = '2010-09-15T00:00:00.000' ;
1419
+ $rootScope . isopen = true ;
1420
+ var wrapper = $compile ( '<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" timeless-json-mode="withUtils" timeless-json-utils="true" max-date="jsonDateToTicks(date, 1)" is-open="isopen"></div>' ) ( $rootScope ) ;
1421
+ $rootScope . $digest ( ) ;
1422
+ assignElements ( wrapper ) ;
1423
+ } ) ) ;
1424
+
1425
+ it ( 'jsonDateToTicks/jsonDateAddDays should be on parent scope and work with max-date' , function ( ) {
1426
+ expect ( getAllOptionsEl ( ) . eq ( 19 ) . prop ( 'disabled' ) ) . toBe ( true ) ;
1427
+ } ) ;
1428
+ } ) ;
1429
+
1257
1430
describe ( 'setting datepickerPopupConfig inside ng-if' , function ( ) {
1258
1431
var originalConfig = { } ;
1259
1432
beforeEach ( inject ( function ( uibDatepickerPopupConfig ) {
0 commit comments