Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test does not pass #1

Open
7kaji opened this issue Jan 28, 2021 · 2 comments · May be fixed by #2
Open

test does not pass #1

7kaji opened this issue Jan 28, 2021 · 2 comments · May be fixed by #2

Comments

@7kaji
Copy link

7kaji commented Jan 28, 2021

Thank you for creating a wonderful calendar library.
It is very helpful.

Currently, the test does not pass in my environment.

$ yarn test
...
...
...
  viewOfInterval()
     returns a day interval for day view (2ms)
     returns a week interval for week view (2ms)
     returns a month interval for month view (7ms)
     returns a year interval for year view (30ms)
  viewOfDays()
     returns day intervals for view and datetime (5ms)
...
...
...
    viewOfInterval()  returns a month interval for month view

    expect(received).toBe(expected) // Object.is equality

    Expected: 31
    Received: 42

      87 |     const datetime = DateTime.fromObject({ year: 2019, month: 12, day: 30 });
      88 |     const interval = viewOfInterval(datetime, 'months');
    > 89 |     expect(numUnit(interval, 'days')).toBe(31);
         |                                       ^
      90 |     expect(interval.start.day).toBe(1);
      91 |     expect(interval.end.day).toBe(31);
      92 |   });

      at Object.<anonymous> (test/calx.test.tsx:89:39)

   viewOfDays()  returns day intervals for view and datetime

    expect(received).toBe(expected) // Object.is equality

    Expected: 31
    Received: 42

      108 |     const datetime = DateTime.fromObject({ year: 2019, month: 12, day: 30 });
      109 |     const days = viewOfDays(datetime, 'month');
    > 110 |     expect(days.length).toBe(31);
          |                         ^
      111 |     expect(days[0].start.day).toBe(1);
      112 |     expect(days[30].start.day).toBe(31);
      113 |   });

      at Object.<anonymous> (test/calx.test.tsx:110:25)
...
...
...
Test Suites: 1 failed, 1 total
Tests:       2 failed, 19 passed, 21 total
Snapshots:   0 total
Time:        2.416s, estimated 4s

After looking at the code, I have a few questions.
When do you need the logic for paddedMonthOf()?
It's called in viewOfInterval(), but monthOf(datetime) looks fine to me. In fact, when I rewrote it to monthOf(datetime), the test passed.

era/src/index.ts

Lines 108 to 109 in cc261df

case 'months':
return paddedMonthOf(datetime, { daysPerWeek: 7, weeksPerMonth: 6 });

@hshoff
Copy link
Owner

hshoff commented Feb 1, 2021

Looks like a bug. paddedMonthOf() returns a "square" of days in the month.

For example:

The gray Sept 26-30 & Nov 1-6.

@7kaji
Copy link
Author

7kaji commented Feb 3, 2021

Thanks for the reply.

I see.
I understand the current situation.

@7kaji 7kaji linked a pull request May 2, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants