mischah / itunes-remote

:notes: Control iTunes via CLI
MIT License
427 stars 31 forks source link

Make tests independent of return values from osascript #7

Open Haroenv opened 8 years ago

Haroenv commented 8 years ago

I was planning to contribute to the feature #6, but running tests without changing anything returned (among passing tests) this:

      ✓ should return »✔ Returned to previous track or beginning of current track.« (120ms)
    command `search`
      1) should return success message
      ✓ should return error message when no search results for all (111ms)
      ✓ should return error message when no search results for albums (151ms)
      ✓ should return error message when no search results for songs (146ms)
      ✓ should return error message when no search results for artists (139ms)
    command `getData`
      ✓ should return an object. (157ms)

  12 passing (2s)
  1 failing

  1) itunesRemote command `search` should return success message:

      Uncaught AssertionError: expected '\u001b[31m✖\u001b[39m Oops. Found 0 songs by ”\u001b[7memancipator\u001b[27m“.' to equal '\u001b[32m✔\u001b[39m Found songs by ”\u001b[7memancipator\u001b[27m“ and generated a temporary playlist'
      + expected - actual

      -✖ Oops. Found 0 songs by ”emancipator“.
      +✔ Found songs by ”emancipator“ and generated a temporary playlist

      at itunesRemote.searchterm (test.js:73:25)
      at index.js:194:12
      at index.js:138:13
      at PassThrough.<anonymous> (node_modules/osascript/index.js:63:12)
      at endReadableNT (_stream_readable.js:903:12)
Haroenv commented 8 years ago

For reference, I don't have songs by "emancipator" in my library.

mischah commented 8 years ago

For reference, I don't have songs by "emancipator" in my library.

That’s the problem. You need songs by Emancipator to contribute :joy:

All joking aside. The test are incomplete and not real unit tests. They have dependencies to your iTunes library (as the return values of osascript).

This is a design failure of the test. I guess I should mock the return values with Sinon to get rid of that dependency. I never done that before :grin: But seems to be about that time.