Skip to content

Commit

Permalink
test(link): add afterEach function to reset all Mocks to ensure warni…
Browse files Browse the repository at this point in the history
…ngs work properly
  • Loading branch information
lzcabrera committed Aug 18, 2017
1 parent dedb598 commit d723553
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/Link/ButtonLink/__tests__/ButtonLink.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ describe('Link.Button', () => {
<Link.Button {...overrides}>Go home</Link.Button>
)

afterEach(() => {
jest.clearAllMocks()
})

it('is an anchor HTML element when using the href attribute', () => {
const link = doShallow({ href: 'http://telus.com' })

Expand All @@ -34,6 +38,8 @@ describe('Link.Button', () => {

expect(warn).toHaveBeenCalled()

jest.clearAllMocks()

link = doShallow({ to: '/about' })

expect(link).toHaveProp('to')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ describe('Link.Chevron', () => {
<Link.Chevron {...overrides}>Go home</Link.Chevron>
)

afterEach(() => {
jest.clearAllMocks()
})

it('is an anchor HTML element when using the href attribute', () => {
const link = doShallow({ href: 'http://telus.com' })

Expand All @@ -34,6 +38,8 @@ describe('Link.Chevron', () => {

expect(warn).toHaveBeenCalled()

jest.clearAllMocks()

link = doShallow({ to: '/about' })

expect(link).toHaveProp('to')
Expand Down
7 changes: 7 additions & 0 deletions src/components/Link/__tests__/Link.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ jest.mock('../../../warn', () => (
{ warn: jest.fn() }
))


describe('Link', () => {
const doShallow = (overrides = {}) => shallow(
<Link {...overrides}>Go home</Link>
)

afterEach(() => {
jest.clearAllMocks()
})

it('renders', () => {
const link = doShallow()

Expand All @@ -40,6 +45,8 @@ describe('Link', () => {

expect(warn).toHaveBeenCalled()

jest.clearAllMocks()

link = doShallow({ to: '/about' })

expect(link).toHaveProp('to')
Expand Down

0 comments on commit d723553

Please sign in to comment.