forked from t1m0n/air-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added swapping dates when range is true, fixes t1m0n#46
- Loading branch information
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
describe('API', function () { | ||
|
||
var assert = chai.assert, | ||
expect = chai.expect, | ||
destroy = true, | ||
$altInput, | ||
$input, dp; | ||
|
||
before(function () { | ||
$input = $('<input>').appendTo('#container'); | ||
$altInput = $('<input class="alt-field">').appendTo('#container'); | ||
}); | ||
|
||
afterEach(function () { | ||
if (dp && destroy) { | ||
dp.destroy(); | ||
} | ||
|
||
destroy = true; | ||
}); | ||
|
||
after(function () { | ||
$input.remove(); | ||
$altInput.remove(); | ||
}); | ||
|
||
describe('selectDate', function () { | ||
it('should select passed date', function () { | ||
dp = $input.datepicker().data('datepicker'); | ||
|
||
var date = new Date(); | ||
|
||
dp.selectDate(date); | ||
|
||
expect(dp.selectedDates).to.have.length(1); | ||
expect(dp.selectedDates[0]).to.be.equal(date) | ||
}); | ||
it('should select multiple dates if {multipleDates: true}', function () { | ||
dp = $input.datepicker({ | ||
multipleDates: true | ||
}).data('datepicker'); | ||
|
||
var date = new Date(2016, 4, 16), | ||
date2 = new Date(2016, 4, 18); | ||
|
||
dp.selectDate(date); | ||
dp.selectDate(date2); | ||
|
||
expect(dp.selectedDates).to.have.length(2); | ||
}); | ||
it('should swap dates if {range: true} and second date is smaller then first', function () { | ||
dp = $input.datepicker({ | ||
range: true | ||
}).data('datepicker'); | ||
|
||
var date = new Date(2016, 4, 18), | ||
date2 = new Date(2016, 4, 16); | ||
|
||
dp.selectDate(date); | ||
dp.selectDate(date2); | ||
|
||
expect(dp.selectedDates[0]).to.be.equal(date2); | ||
}) | ||
}); | ||
}); |