Skip to content

Commit

Permalink
Merge pull request onefinestay#143 from onefinestay/fix-broken-weeken…
Browse files Browse the repository at this point in the history
…d-date-tests

Fix broken weekend date tests
  • Loading branch information
AlanFoster authored Jul 4, 2016
2 parents ccdaaba + 9e06530 commit c3501ce
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/calendar/tests/CalendarDate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import CalendarSelection from '../CalendarSelection';


describe('The CalendarDate Component', function () {
const today = () => moment("2014-01-01T12:00:00Z");

beforeEach(function () {

const getCalendarDate = (props) => {

props = _.extend({
date: moment(),
firstOfMonth: moment(),
date: today(),
firstOfMonth: today(),
dateRangesForDate: function () {
return {
count: function () {
Expand Down Expand Up @@ -86,21 +87,19 @@ describe('The CalendarDate Component', function () {

describe('sets the correct class', function () {

it('by defininig the expected class name', function () {
it('by defining the expected class name', function () {
this.useShallowRenderer();
expect(this.renderedComponent.props.className).toEqual('DateRangePicker__Date');
});

describe('by setting the expected bem modifiers', function () {

it('when the provided date is today', function () {
this.useShallowRenderer({
isToday: true,
});
expect(this.renderedComponent.props.className).toEqual('DateRangePicker__Date DateRangePicker__Date--today');
});


it('when the provided date is not today', function () {
this.useShallowRenderer({
isToday: false,
Expand All @@ -109,7 +108,7 @@ describe('The CalendarDate Component', function () {
});

it('when the provided date is over the weekend', function () {
var nextSunday = moment().day(7);
var nextSunday = today().day(7);
this.useShallowRenderer({
date: nextSunday,
});
Expand All @@ -118,16 +117,16 @@ describe('The CalendarDate Component', function () {


it('when the provided date is not over the weekend', function () {
let nextMonday = moment().day(8);
let nextMonday = today().day(8);
this.useShallowRenderer({
date: nextMonday,
});
expect(this.renderedComponent.props.className).not.toContain('DateRangePicker__Date--weekend');
});

it('when the provided date is during the same month', function () {
let date = moment().date(8).month(3),
firstOfMonth = moment().date(1).month(3);
let date = today().date(8).month(3),
firstOfMonth = today().date(1).month(3);
this.useShallowRenderer({
date: date,
firstOfMonth: firstOfMonth,
Expand All @@ -137,8 +136,8 @@ describe('The CalendarDate Component', function () {


it('when the provided date is not during the same month', function () {
let date = moment().date(8).month(3),
firstOfMonth = moment().date(1).month(43);
let date = today().date(8).month(3),
firstOfMonth = today().date(1).month(43);
this.useShallowRenderer({
date: date,
firstOfMonth: firstOfMonth,
Expand Down Expand Up @@ -255,7 +254,7 @@ describe('The CalendarDate Component', function () {
//Workaround as suggested from https://github.com/facebook/react/issues/1297

beforeEach(function(){
this.date = moment();
this.date = today();
this.useDocumentRenderer({
date: this.date,
});
Expand Down

0 comments on commit c3501ce

Please sign in to comment.