Skip to content
New issue

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

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

Already on GitHub? # to your account

test(LocationsCommand): add inital unit tests #157

Merged
merged 1 commit into from
Feb 8, 2021

Conversation

john-u
Copy link
Contributor

@john-u john-u commented Feb 5, 2021

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • I have read the CONTRIBUTING document
  • My code follows the code style of this project (lerna run lint produces no warnings/errors)
  • Any required documentation has been added
  • I have added tests to cover my changes

@john-u john-u requested review from bflorian and rossiam February 5, 2021 22:57
@john-u john-u force-pushed the test-locations-command branch from 91921d4 to 0f1c165 Compare February 8, 2021 15:52
@john-u john-u marked this pull request as ready for review February 8, 2021 15:53
})

describe('LocationsCommand', () => {
const mockListing = outputListing as unknown as jest.Mock<typeof outputListing>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems required with Typescript in order to use anything useful in the jest mock API.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably do something like this:

const outputListingMock = jest.fn()
jest.mock('@smarthings/cli-lib', () => {
...
  return {
    ...originalLib,
    outputListing: outputListingMock,
  }
})

And then use outputListingMock instead.

Copy link
Contributor Author

@john-u john-u Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot that I tried that first and ran into this issue. It may be a temporary bug.

@john-u john-u merged commit c08ac92 into SmartThingsCommunity:master Feb 8, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants