Git Product home page Git Product logo

era's People

Contributors

hshoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

era's Issues

test does not pass

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 });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.