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

two niceDate tests fail, assuming due to DST difference #24

Closed
jeffkpayne opened this issue Jan 13, 2018 · 0 comments
Closed

two niceDate tests fail, assuming due to DST difference #24

jeffkpayne opened this issue Jan 13, 2018 · 0 comments

Comments

@jeffkpayne
Copy link

jeffkpayne commented Jan 13, 2018

Looks like since both the niceDate function and the test itself are using new Date(string), which uses local time, the tests which include those code paths fail in some timezones (mine, PST).

Have you considered using a library like moment.js? Guessing that could reduce your niceDate function down to a couple lines of code, but not sure if you want that dependency...

This illustrates the problem and possible solution in the node repl:

> new Date('2015-10-03').getDate()
2
> new Date(2015, 9, 3).getDate()
3
> const moment = require('moment');
undefined
> moment('2015-10-03').format('D MMMM YYYY')
'3 October 2015'

Here's the output from node test:

> auto-changelog@1.3.0 test /Users/jpayne/repos/auto-changelog
> cross-env NODE_ENV=test nyc mocha test



  fetchCommits
    ✓ fetches commits

  parseCommits
    ✓ parses commits
    ✓ parses bitbucket commit
    ✓ supports startingCommit option
    ✓ invalid startingCommit throws an error

  getFixes
    ✓ returns null with no fixes
    ✓ parses a single fix
    ✓ parses fix in commit notes
    ✓ parses a commit that closes a pull request
    ✓ parses a commit that closes a bitbucket pull request
    ✓ parses a commit that closes a gitlab pull request
    ✓ parses multiple fixes
    ✓ parses fixes by issue URL
    ✓ parses multiple fixes by issue URL
    ✓ parses external repo issues
    ✓ supports issueUrl parameter
    ✓ supports issuePattern parameter
    ✓ supports issuePattern parameter with capture group

  getMerge
    ✓ returns null on fail
    GitHub
      ✓ parses a merge
      ✓ parses a squash merge
      ✓ parses a squash merge with no message
    GitLab
      ✓ parses a merge
    BitBucket
      ✓ parses a merge

  fetchOrigin
    ✓ parses https://github.com/user/repo
    ✓ parses https://github.com:8080/user/repo
    ✓ parses git@github.com:user/repo.git
    ✓ parses https://gitlab.com/user/repo
    ✓ parses git@gitlab.com:user/repo.git
    ✓ parses https://bitbucket.org/user/repo
    ✓ parses git@bitbucket.org:user/repo.git
    ✓ throws an error

  parseReleases
    ✓ parses releases
    ✓ parses releases with no commit limit
    ✓ parses bitbucket releases
    ✓ supports a version override

  getOptions
    ✓ parses commit limit correctly
    ✓ parses false commit limit correctly

  run
    ✓ generates a changelog
    ✓ uses options from package.json
    ✓ uses version from package.json
    ✓ command line options override options from package.json
    ✓ does not error when using unreleased option
    ✓ does not error when using latest version option
    ✓ throws an error when no package found
    ✓ throws an error when no template found
    ✓ throws an error when given an invalid latest version

  compileTemplate
    ✓ compiles using compact template
    ✓ compiles using keepachangelog template
    ✓ compiles using json template
    ✓ compiles using path to template file
    ✓ throws an error when no template found

  cmd
    ✓ runs a command

  niceDate
    1) formats string into nice date
    2) formats date into nice date

  removeIndentation
    ✓ removes indentation

  isLink
    ✓ returns true for links
    ✓ returns false for non-links


  56 passing (195ms)
  2 failing

  1) niceDate
       formats string into nice date:

      AssertionError: expected '2 October 2015' to equal '3 October 2015'
      + expected - actual

      -2 October 2015
      +3 October 2015

      at Context.<anonymous> (test/utils.js:15:39)

  2) niceDate
       formats date into nice date:

      AssertionError: expected '2 October 2015' to equal '3 October 2015'
      + expected - actual

      -2 October 2015
      +3 October 2015

      at Context.<anonymous> (test/utils.js:21:49)



-------------|----------|----------|----------|----------|----------------|
File         |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-------------|----------|----------|----------|----------|----------------|
All files    |      100 |       95 |      100 |      100 |                |
 commits.js  |      100 |    92.68 |      100 |      100 |       42,79,80 |
 origin.js   |      100 |    83.33 |      100 |      100 |             11 |
 releases.js |      100 |    96.97 |      100 |      100 |             37 |
 run.js      |      100 |      100 |      100 |      100 |                |
 template.js |      100 |      100 |      100 |      100 |                |
 utils.js    |      100 |      100 |      100 |      100 |                |
-------------|----------|----------|----------|----------|----------------|
npm ERR! Test failed.  See above for more details.

Let me know and I can open a PR.

jeffkpayne added a commit to bomboradata/bombora-auto-changelog that referenced this issue Jan 14, 2018
jeffkpayne added a commit to bomboradata/bombora-auto-changelog that referenced this issue Jan 14, 2018
b6pzeusbc54tvhw5jgpyw8pwz2x6gs pushed a commit to b6pzeusbc54tvhw5jgpyw8pwz2x6gs/auto-changelog that referenced this issue Sep 19, 2018
Feels cleaner to use http://shields.io for everything

Remove todo list from readme

Should ideally be issues on github

Add option for specifying output file

Fixes cookpete#1 and cleans stuff up a bit

Add newline at end of generated logs

Add support for --package

Uses the version from package.json as the latest version, which lets you do cool stuff like generating a changelog as part of a version bump commit, see README.md for more

Generate changelog on version

0.1.0

Fix --package bug

Prefixing inside generateLog caused the param to always be truthy, which messed up parseReleases

Explicitly render links for PRs and issues

GitHub doesn't automatically parse them in markdown files like it does for PRs, issues and comments

0.1.1

Add FAQ to readme

Rearrange usage docs

Add support for specifying templates

Also add a simple compact template

Start using compact changelog

It just seems.. nicer

Lint and test before versioning

0.2.0

Replace toLocaleString usage with months array

Not supported in node 0.10

0.2.1

Update templating logic

Cleans up how logs are rendered
Keeps things DRY between the two templates

More sensible formatDate

There was no point making it an external function in Compact when it's already a class method in Default

Add a commit-only release to test data

Beefs up the rendering tests a bit, covering more bases

0.2.2

Add support for minimumChangeCount in templates

Backfill release notes with commits up to the given threshold
Prevents releases that list only a single merge or fix, even if larger changes may have been commited as well

Add semicolons after class properties

To support babel 6.4.x

Remove unique issue filter

Broken since storing several issues per commit, so now causes more problems than it solves

Case insensitive issue URL parsing

0.3.0

Bump packages

Lint fixes

Correct find polyfill usage

More robust log separators

Improve cmd util

Improve origin URL parsing

Fixes cookpete#2 and fixes cookpete#5

Improve error handling

Add extra commits test

Use template literal for success string

Bump packages

Remove semicolons

No longer required with latest version of standard

0.3.1

Prevent duplicate commits being listed

Fixes cookpete#3

0.3.2

Lint fix

Bump packages

And add yarn lockfile
Fixes cookpete#7

Use babel-preset-env

0.3.3

Update travis to use later versions of node

Add code coverage

Remove parseInt radix

No longer required by standard

Fix travis node versions

Tweak default template date format

Disable codecov comments and build status

Add yarn cache to travis config

Generate coverage reports when testing locally

Remove need for array.find polyfill

Use async/await instead of promises

Tweak version script

0.3.4

Add babel-polyfill

Fixes cookpete#8
Requires babel-polyfill to be imported before the main file due to aggressing async function hoisting
babel/babel#6206

0.3.5

Use origin hostname instead of host

`host` includes the port number, which can break links
Hopefully fixes cookpete#9

Correct bitbucket compare URLs

0.3.6

Improved issue matching

Now supports any generic issue URL that contains `/issues/{number}`

Update dependencies to enable Greenkeeper 🌴 (cookpete#10)

* chore(package): update dependencies

* docs(readme): add Greenkeeper badge

Tweak readme badges

Remove dependency status badges

With greenkeeper enabled, they will pretty much always been up to date, right?

Refactor codebase

Add greenkeeper-lockfile support

1.0.0

Update readme

Filter out commits with the same message as an existing merge

1.0.1

Tweak package read logic

Fall back to https origin protocol

1.0.2

Tweak version script

Fix pull request URL

Bump packages

Limit origin protocol to http or https

Fix version script

babel-node was erroring when using -p

1.0.3

Tidy options logic

Keep coverage files inside test directory

Tweak origin properties

Add origin tests

Add script to generate test data

Update clean script

Refactor run logic

Add run tests

Move test origins to separate file

Exclude index.js from test coverage

Remove unused options param from cmd util

Tweak removeIndentation util

Add util tests

Fix multiple issue URL parsing

Support modifying commit limit with --commit-limit (cookpete#12)

* Support modifying commit limit with --commit-limit

* Tidy up commit limit logic

1.1.0

Update readme

Parse squash merge commits with no commit message

Update formatting of shameless plug in templates

Add npm script for generating test data

Parse squash commits with broken messages

Slightly larger heading for major releases

Add major release to test data

Add issue-url option to override issue URLs

Fixes cookpete#13

Add basic requirements to readme

1.2.0

Use commander instance

Increase test coverage

Add commit with matching PR message to test data

To ensure the commit is filtered out of changelogs

Add commit to test data to trigger sorting

Add tests

Remove support for broken message squash merge

Filter out merge commits

Closes cookpete#14

Parse commits that close pull requests

1.2.1

Fix error when using --unreleased flag

Fixes cookpete#16

1.2.2

Update fs-extra to the latest version 🚀 (cookpete#19)

* fix(package): update fs-extra to version 5.0.0

* chore(package): update lockfile

https://npm.im/greenkeeper-lockfile

Add --latest-version option

Closes cookpete#17

Update tests

Add --issue-pattern option

Closes cookpete#18

Override package options with command line options

Add --starting-commit option

Closes cookpete#21

1.3.0

Add merge commit to test data

Add package version test

Add --tag-prefix option

Closes cookpete#22

Add --ignore-commit-pattern option

Update niceDate tests to avoid timezone issues

Fixes cookpete#24
Closes cookpete#25
The formatting is the main thing we want to test, not the exact date being correct (we can assume the JS engine will not fail us).

Add support for generating logs without a git remote

Fixes cookpete#23

Change use of "origin" to "remote"

"origin" doesn't really make sense, as it is just the name of the default remote for most repos
"remote" is more correct in the context of the code

Fix tag prefix logic

Update mocha to the latest version 🚀 (cookpete#26)

* chore(package): update mocha to version 5.0.0

* chore(package): update lockfile

https://npm.im/greenkeeper-lockfile

1.4.0

Support commits with no message

Fixes cookpete#27

1.4.1

Update standard to the latest version 🚀 (cookpete#29)

* chore(package): update standard to version 11.0.0

* chore(package): update lockfile

https://npm.im/greenkeeper-lockfile

* Lint fix

Support for gitlab subgroups and self-hosted instances (cookpete#28)

1.4.2

Add tag prefix to compare URLs

Fixes cookpete#30

1.4.3

Do not show date for unreleased section

Fixes cookpete#31

Fix unreleased compare URL

1.4.4

Correctly prefix package version

Fixes cookpete#33

1.4.5

Added support for old git versions (cookpete#35)

1.4.6

Use UTC dates by default

Fixes cookpete#37

Add commit-list template helper

Fixes cookpete#36 and fixes cookpete#39

Remove unused imports from template tests

Feat: match template helper (cookpete#40)

Move helper tests to separate files

1.5.0

Add --include-branch option

Fixes cookpete#38

Fix duplicate test data commit hashes

Add --breaking-pattern option

Fixes cookpete#41

1.6.0

Add replaceText package option

1.7.0

Fix releases sorting when unreleased enabled (cookpete#45)

Update git log format to support earlier git versions

Fixes cookpete#43

Use async fs utils instead of fs-extra

Closes cookpete#42
Also, tidies up imports

1.7.1

Remove node 4 and 5 from travis builds

Enable partial line coverage with codecov

Also move coverage into root

Use %B for supported git versions

The fallback was causing problems for commit messages with single newlines

Add engines to package.json

Add markdown linting

Fixes cookpete#47

Fix changelog spacing
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

No branches or pull requests

1 participant