Blame view

tests/methods.js 1.53 KB
5c8f10d65   Tom Huang   start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  var Pikaday = require('../'),
      expect = require('expect.js');
  
  describe('Pikaday public method', function ()
  {
      'use strict';
  
      describe('#toString()', function ()
      {
          it('should return empty string when date not set', function ()
          {
              var pikaday = new Pikaday();
              expect(pikaday.toString()).to.be.empty;
          });
  
          it('should return date string, formatted by moment, when date is set', function() {
              var date = new Date(2014, 3, 25),
              pikaday = new Pikaday({
                  format: 'DD-MM-YY'
              });
  
              pikaday.setDate(date);
              expect(pikaday.toString()).to.eql('25-04-14');
          });
      });
  
      describe('When specifying minDate option in Constructor', function () {
          it('Should remove the time portion (flattening to midnight)', function () {
              var date = new Date(2015, 1, 17, 22, 10, 5),
                  expected = new Date(2015, 1, 17, 0, 0, 0),
                  pikaday = new Pikaday({ minDate: date });
  
              expect(pikaday._o.minDate).to.eql(expected);
          });
      });
  
      describe('#setMinDate()', function () {
          it('should flatten date to midnight ignoring time portion (consistent with minDate option in ctor)', function () {
              var date = new Date(2015, 1, 17, 22, 10, 5),
                  expected = new Date(2015, 1, 17, 0, 0, 0),
                  pikaday = new Pikaday();
  
              pikaday.setMinDate(date);
              expect(pikaday._o.minDate).to.eql(expected);
          });
      });
  });