|
|
@@ -96,7 +96,7 @@ describe('luxon plugin', function() {
|
|
|
|
|
|
})
|
|
|
|
|
|
- describe('formatting', function() {
|
|
|
+ describe('date formatting', function() {
|
|
|
|
|
|
it('produces event time text', function() {
|
|
|
initCalendar({
|
|
|
@@ -112,15 +112,67 @@ describe('luxon plugin', function() {
|
|
|
expect(getEventElTimeText(getSingleEl())).toBe('13:30:20abc')
|
|
|
})
|
|
|
|
|
|
- xit('produces title with titleRangeSeparator', function() {
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('range formatting', function() {
|
|
|
+
|
|
|
+ it('renders with same month', function() {
|
|
|
+ let calendar = new FullCalendar.Calendar(document.createElement('div'), {
|
|
|
+ cmdFormatter: 'luxon'
|
|
|
+ })
|
|
|
+ let s
|
|
|
+
|
|
|
+ s = calendar.formatRange('2018-09-03', '2018-09-05', 'MMMM {d}, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('September 3 - 5, 2018 asdf')
|
|
|
+
|
|
|
+ s = calendar.formatRange('2018-09-03', '2018-09-05', '{d} MMMM, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('3 - 5 September, 2018 asdf')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('renders with same year but different month', function() {
|
|
|
+ let calendar = new FullCalendar.Calendar(document.createElement('div'), {
|
|
|
+ cmdFormatter: 'luxon'
|
|
|
+ })
|
|
|
+ let s
|
|
|
+
|
|
|
+ s = calendar.formatRange('2018-09-03', '2018-10-05', '{MMMM {d}}, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('September 3 - October 5, 2018 asdf')
|
|
|
+
|
|
|
+ s = calendar.formatRange('2018-09-03', '2018-10-05', '{{d} MMMM}, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('3 September - 5 October, 2018 asdf')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('renders with different years', function() {
|
|
|
+ let calendar = new FullCalendar.Calendar(document.createElement('div'), {
|
|
|
+ cmdFormatter: 'luxon'
|
|
|
+ })
|
|
|
+ let s
|
|
|
+
|
|
|
+ s = calendar.formatRange('2018-09-03', '2019-10-05', '{MMMM {d}}, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('September 3, 2018 asdf - October 5, 2019 asdf')
|
|
|
+
|
|
|
+ s = calendar.formatRange('2018-09-03', '2019-10-05', '{{d} MMMM}, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('3 September, 2018 asdf - 5 October, 2019 asdf')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('inherits defaultRangeSeparator', function() {
|
|
|
+ let calendar = new FullCalendar.Calendar(document.createElement('div'), {
|
|
|
+ cmdFormatter: 'luxon',
|
|
|
+ defaultRangeSeparator: ' to '
|
|
|
+ })
|
|
|
+ let s = calendar.formatRange('2018-09-03', '2018-09-05', 'MMMM d, yyyy \'asdf\'')
|
|
|
+ expect(s).toEqual('September 3, 2018 asdf to September 5, 2018 asdf')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('produces title with titleRangeSeparator', function() {
|
|
|
initCalendar({ // need to render the calendar to get view.title :(
|
|
|
defaultView: 'basicWeek',
|
|
|
now: '2018-09-06',
|
|
|
cmdFormatter: 'luxon',
|
|
|
- titleFormat: 'MMMM {d} yy \'abc\'',
|
|
|
+ titleFormat: 'MMMM {d} yy \'yup\'',
|
|
|
titleRangeSeparator: ' to '
|
|
|
})
|
|
|
- expect(currentCalendar.view.title).toBe('September 2 to 8 18 abc')
|
|
|
+ expect(currentCalendar.view.title).toBe('September 2 to 8 18 yup')
|
|
|
})
|
|
|
|
|
|
})
|