Skip to content

Commit

Permalink
test(ui/QDate): improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
n05la3 authored and IlCallo committed Feb 23, 2024
1 parent 3a40e49 commit 9a1702d
Showing 1 changed file with 41 additions and 37 deletions.
78 changes: 41 additions & 37 deletions ui/src/components/date/__tests__/QDate.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import { date } from 'quasar'

const { formatDate, addToDate } = date

function mountQDate (options) {
return cy.mount(QDate, options)
}

describe('Date API', () => {
describe.skip('Props', () => {
describe('Props', () => {
describe('Category: behavior', () => {
describe('(prop): years-in-month-view', () => {
it.skip(' ', () => {
Expand All @@ -15,12 +19,12 @@ describe('Date API', () => {
})
})

describe.skip('Category: content', () => {
describe('Category: content', () => {
describe('(prop): title', () => {
it('should override the default title header', () => {
const title = 'Birthday'

cy.mount(QDate, {
mountQDate({
props: {
title
}
Expand All @@ -35,7 +39,7 @@ describe('Date API', () => {
it('should override the default subtitle', () => {
const subtitle = 'Birthday'

cy.mount(QDate, {
mountQDate({
props: {
subtitle
}
Expand All @@ -55,7 +59,7 @@ describe('Date API', () => {

const today = formatDate(currentDate, format)

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(fiveDaysFromToday),
todayBtn: true
Expand Down Expand Up @@ -89,7 +93,7 @@ describe('Date API', () => {

describe('(prop): minimal', () => {
it('should hide the header', () => {
cy.mount(QDate, {
mountQDate({
props: {
minimal: true
}
Expand All @@ -101,12 +105,12 @@ describe('Date API', () => {
})
})

describe.skip('Category: model', () => {
describe('Category: model', () => {
describe('(prop): model-value', () => {
it('should select the correct date based on the model value', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model)
}
Expand All @@ -128,7 +132,7 @@ describe('Date API', () => {

describe('(prop): default-year-month', () => {
it('should display the date picker with a default year and month', () => {
cy.mount(QDate, {
mountQDate({
props: {
defaultYearMonth: '1986/01'
}
Expand All @@ -150,7 +154,7 @@ describe('Date API', () => {
it('should display with a default years view', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
defaultView: 'Years'
Expand All @@ -168,7 +172,7 @@ describe('Date API', () => {
it('should display with a default months view', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
defaultView: 'Months'
Expand All @@ -186,7 +190,7 @@ describe('Date API', () => {
it('should display with a default calendar view', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
defaultView: 'Calendar'
Expand All @@ -207,7 +211,7 @@ describe('Date API', () => {
it('should highlight a single event on the calendar', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
events: '2018/06/12'
Expand All @@ -223,7 +227,7 @@ describe('Date API', () => {
it('should highlight multiple events on the calendar', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
events: [ '2018/06/12', '2018/06/17', '2018/06/20' ]
Expand All @@ -241,7 +245,7 @@ describe('Date API', () => {
it('should highlight an event on the calendar using a function', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
events: (date) => date > '2018/06/28'
Expand All @@ -261,7 +265,7 @@ describe('Date API', () => {
const model = ref('2018/06/03')

const options = [ 10, 13, 15, 17, 30 ]
cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
options: options.map((day) => `2018/06/${ day }`)
Expand All @@ -283,7 +287,7 @@ describe('Date API', () => {
it('should set a limited options for selection using a function', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
options: (date) => date > '2018/06/28'
Expand All @@ -308,7 +312,7 @@ describe('Date API', () => {
it('should set the first day of the week', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
firstDayOfWeek: '2'
Expand Down Expand Up @@ -340,7 +344,7 @@ describe('Date API', () => {
const model = ref('2018/06/03')

const fn = cy.stub()
cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
'onUpdate:modelValue': fn,
Expand Down Expand Up @@ -368,7 +372,7 @@ describe('Date API', () => {
it('should not select multiple days by default', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model)
}
Expand All @@ -389,7 +393,7 @@ describe('Date API', () => {
it('should select multiple days', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
multiple: true
Expand All @@ -413,7 +417,7 @@ describe('Date API', () => {
it('should select a date range', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
range: true
Expand Down Expand Up @@ -453,7 +457,7 @@ describe('Date API', () => {
it('should prevent user from navigating below a specific year+month', () => {
const model = ref('2018/05/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
navigationMinYearMonth: '2018/03'
Expand Down Expand Up @@ -493,7 +497,7 @@ describe('Date API', () => {
it('should prevent a user from navigating above a specific year+month', () => {
const model = ref('2018/05/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
navigationMaxYearMonth: '2018/07'
Expand Down Expand Up @@ -533,7 +537,7 @@ describe('Date API', () => {
it('should prevent deselecting a day after it has been selected', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
multiple: true
Expand Down Expand Up @@ -570,7 +574,7 @@ describe('Date API', () => {
it('should mark an event on the calendar using a custom color', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
events: [ '2018/06/12' ],
Expand All @@ -592,7 +596,7 @@ describe('Date API', () => {
describe('Slots', () => {
describe('(slot): default', () => {
it('should render a default slot', () => {
cy.mount(QDate, {
mountQDate({
slots: {
default: () => 'Default'
}
Expand All @@ -604,13 +608,13 @@ describe('Date API', () => {
})
})

describe.skip('Events', () => {
describe('Events', () => {
describe('(event): update:model-value', () => {
it('should emit update:model-value event when selecting new date', () => {
const model = ref('2018/06/03')

const fn = cy.stub()
cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
todayBtn: true,
Expand All @@ -634,7 +638,7 @@ describe('Date API', () => {
const model = ref('2018/06/03')

const fn = cy.stub()
cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
onNavigation: fn
Expand Down Expand Up @@ -662,7 +666,7 @@ describe('Date API', () => {
const model = ref('2018/06/03')

const fn = cy.stub()
cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
range: true,
Expand All @@ -686,7 +690,7 @@ describe('Date API', () => {
const model = ref('2018/06/03')

const fn = cy.stub()
cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
range: true,
Expand Down Expand Up @@ -714,7 +718,7 @@ describe('Date API', () => {
it('should set the selected date to today using the setToday method', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model)
}
Expand All @@ -738,7 +742,7 @@ describe('Date API', () => {
it('should use the setView method to set the view', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model)
}
Expand All @@ -761,7 +765,7 @@ describe('Date API', () => {
it('should decrement or increment the month or year calendar', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model)
}
Expand Down Expand Up @@ -799,7 +803,7 @@ describe('Date API', () => {
it('should set the current month and year using the setCalendar method', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model)
}
Expand All @@ -823,7 +827,7 @@ describe('Date API', () => {
it('should set the editing range using the setEditingRange method', () => {
const model = ref('2018/06/03')

cy.mount(QDate, {
mountQDate({
props: {
...vModelAdapter(model),
range: true
Expand Down

0 comments on commit 9a1702d

Please sign in to comment.