Skip to content

Commit

Permalink
Merge ea1fb4f into 7056546
Browse files Browse the repository at this point in the history
  • Loading branch information
MontolioV committed Jun 21, 2019
2 parents 7056546 + ea1fb4f commit 2241a00
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/PickerDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
:key="day.timestamp"
:class="dayClasses(day)"
v-html="dayCellContent(day)"
@click="selectDate(day)"></span>
@click="selectDate(day)"></span><!--
--><span class="cell day blank" v-for="n in blankAppend" :key="'blank-append' + n"></span>
</div>
</div>
</template>
Expand Down Expand Up @@ -83,6 +84,16 @@ export default {
}
return this.utils.getDay(dObj)
},
blankAppend () {
let dayCellsCount = this.days.length + this.blankDays
if (dayCellsCount === 28 || dayCellsCount === 35 || dayCellsCount === 42) {
return 0
} else if (dayCellsCount < 35) {
return 35 - dayCellsCount
} else {
return 42 - dayCellsCount
}
},
/**
* @return {Object[]}
*/
Expand Down
39 changes: 39 additions & 0 deletions test/unit/specs/PickerDay/cellsAmount.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PickerDay from '@/components/PickerDay.vue'
import {shallow} from '@vue/test-utils'
import {en} from '@/locale'

describe('PickerDay: DOM table-like structure', () => {
it('should render 28 cells', () => {
let wrapper = shallow(PickerDay, {
propsData: {
allowedToShowView: () => true,
translation: en,
pageDate: new Date(2015, 1, 1),
selectedDate: new Date(2015, 1, 1)
}
})
expect(wrapper.findAll('.day')).toHaveLength(28)
})
it('should render 35 cells', () => {
let wrapper = shallow(PickerDay, {
propsData: {
allowedToShowView: () => true,
translation: en,
pageDate: new Date(2019, 6, 1),
selectedDate: new Date(2019, 6, 1)
}
})
expect(wrapper.findAll('.day')).toHaveLength(35)
})
it('should render 42 cells', () => {
let wrapper = shallow(PickerDay, {
propsData: {
allowedToShowView: () => true,
translation: en,
pageDate: new Date(2019, 5, 1),
selectedDate: new Date(2019, 5, 1)
}
})
expect(wrapper.findAll('.day')).toHaveLength(42)
})
})

0 comments on commit 2241a00

Please sign in to comment.