Skip to content

Fixes bugs with Min/MaxMonth and adds a lot of new tests#26

Merged
KidSysco merged 10 commits into
KidSysco:masterfrom
benjamin-albert:master
Nov 2, 2015
Merged

Fixes bugs with Min/MaxMonth and adds a lot of new tests#26
KidSysco merged 10 commits into
KidSysco:masterfrom
benjamin-albert:master

Conversation

@benjamin-albert
Copy link
Copy Markdown
Collaborator

While writing unit tests for the Min/MaxMonth options I discovered and fixed a couple of bugs with those options.

The bugs were a result of storing and calculating the min/max month values using JavaScript Date objects where the unnecessary day of month could cause the calculated date object to end up in the next month.

For example if today is October 31 and the MinMonth is 1 (+1 month a.k.a November) the calculated date would end up being December 1 because November doesn't have a 31'st day of month.

I fixed this and many other day of month related bugs by switching the internal representation of the Min/Max month values from a JavaScript Date objects to a number corresponding to ( (Year * 12) + (Month - 1) ) which rules out any kind of issues caused by the day of month and results in a smaller minified file.

I've also fixed a bug that caused the _showYears method to unnecessarily expose two globals.
I've prevented most of these common errors by enabling strict mode.

Luckily we can completely prevent polluting the global namespace by checking the 'Check for globals' option in QUnit.

I've added:

  • Min/MaxMonth module with 6 tests (and 50 assertions).
  • A test for the ShowOn option.
  • A test for the IsRTL option.
  • A test that ensures all events are triggered as expected.
  • A test for the Toggle method.

I've also fixed some small issues with the README.md and the fiddle.

benjamin-albert and others added 10 commits October 28, 2015 06:44
Passing in any type to Min/MaxMonth except for a month string would:
1. Prevent January (1) of any year from being enabled and in some cases would
lead the an entire year being disabled.

2. If the current day of month is greater than 28 and the max/max month
would evaluate to February (2) then March (3) would become enabled.

These bugs were fixed by switching the internal representation of
the Min/Max month values from a JavaScript Date objects to a number
corresponding to ( (Year * 12) + (Month - 1) ) which rules out any
kind of issues caused by the date of month and results in a smaller
minified file.
Adds the Relative month periods test
Adds the JavaScript Date objects test
Adds the Right to left test
This commit also fixes ans issue were the event was not passed to
OnBeforeMenuOpen.
KidSysco added a commit that referenced this pull request Nov 2, 2015
Fixes bugs with Min/MaxMonth and adds a lot of new tests
@KidSysco KidSysco merged commit 5722af9 into KidSysco:master Nov 2, 2015
@KidSysco
Copy link
Copy Markdown
Owner

KidSysco commented Nov 2, 2015

I just merged after looking at it on my machine for a bit. Great work once again, I will update the fiddle next. You are the best thing to happen to this plugin in a very long time Benjamin, I thank you for your efforts!

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 this pull request may close these issues.

2 participants