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

Use jest-matchers for assertions instead of expect #468

Merged
merged 2 commits into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions modules/__tests__/LocationUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('createLocation', () => {
describe('with a full path', () => {
describe('given as a string', () => {
it('has the correct properties', () => {
expect(createLocation('/the/path?the=query#the-hash')).toMatch({
expect(createLocation('/the/path?the=query#the-hash')).toMatchObject({
pathname: '/the/path',
search: '?the=query',
hash: '#the-hash'
Expand All @@ -15,7 +15,7 @@ describe('createLocation', () => {

describe('given as an object', () => {
it('has the correct properties', () => {
expect(createLocation({ pathname: '/the/path', search: '?the=query', hash: '#the-hash' })).toMatch({
expect(createLocation({ pathname: '/the/path', search: '?the=query', hash: '#the-hash' })).toMatchObject({
pathname: '/the/path',
search: '?the=query',
hash: '#the-hash'
Expand All @@ -27,7 +27,7 @@ describe('createLocation', () => {
describe('with a relative path', () => {
describe('given as a string', () => {
it('has the correct properties', () => {
expect(createLocation('the/path?the=query#the-hash')).toMatch({
expect(createLocation('the/path?the=query#the-hash')).toMatchObject({
pathname: 'the/path',
search: '?the=query',
hash: '#the-hash'
Expand All @@ -37,7 +37,7 @@ describe('createLocation', () => {

describe('given as an object', () => {
it('has the correct properties', () => {
expect(createLocation({ pathname: 'the/path', search: '?the=query', hash: '#the-hash' })).toMatch({
expect(createLocation({ pathname: 'the/path', search: '?the=query', hash: '#the-hash' })).toMatchObject({
pathname: 'the/path',
search: '?the=query',
hash: '#the-hash'
Expand All @@ -49,7 +49,7 @@ describe('createLocation', () => {
describe('with a path with no pathname', () => {
describe('given as a string', () => {
it('has the correct properties', () => {
expect(createLocation('?the=query#the-hash')).toMatch({
expect(createLocation('?the=query#the-hash')).toMatchObject({
pathname: '/',
search: '?the=query',
hash: '#the-hash'
Expand All @@ -59,7 +59,7 @@ describe('createLocation', () => {

describe('given as an object', () => {
it('has the correct properties', () => {
expect(createLocation({ search: '?the=query', hash: '#the-hash' })).toMatch({
expect(createLocation({ search: '?the=query', hash: '#the-hash' })).toMatchObject({
pathname: '/',
search: '?the=query',
hash: '#the-hash'
Expand All @@ -71,7 +71,7 @@ describe('createLocation', () => {
describe('with a path with no search', () => {
describe('given as a string', () => {
it('has the correct properties', () => {
expect(createLocation('/the/path#the-hash')).toMatch({
expect(createLocation('/the/path#the-hash')).toMatchObject({
pathname: '/the/path',
search: '',
hash: '#the-hash'
Expand All @@ -81,7 +81,7 @@ describe('createLocation', () => {

describe('given as an object', () => {
it('has the correct properties', () => {
expect(createLocation({ pathname: '/the/path', hash: '#the-hash' })).toMatch({
expect(createLocation({ pathname: '/the/path', hash: '#the-hash' })).toMatchObject({
pathname: '/the/path',
search: '',
hash: '#the-hash'
Expand All @@ -93,7 +93,7 @@ describe('createLocation', () => {
describe('with a path with no hash', () => {
describe('given as a string', () => {
it('has the correct properties', () => {
expect(createLocation('/the/path?the=query')).toMatch({
expect(createLocation('/the/path?the=query')).toMatchObject({
pathname: '/the/path',
search: '?the=query',
hash: ''
Expand All @@ -103,7 +103,7 @@ describe('createLocation', () => {

describe('given as an object', () => {
it('has the correct properties', () => {
expect(createLocation({ pathname: '/the/path', search: '?the=query' })).toMatch({
expect(createLocation({ pathname: '/the/path', search: '?the=query' })).toMatchObject({
pathname: '/the/path',
search: '?the=query',
hash: ''
Expand Down Expand Up @@ -134,12 +134,12 @@ describe('createLocation', () => {
describe('key', () => {
it('has a key property if a key is provided', () => {
const location = createLocation('/the/path', undefined, 'key')
expect(location).toIncludeKey('key')
expect(Object.keys(location)).toContain('key')
})

it('has no key property if no key is provided', () => {
const location = createLocation('/the/path')
expect(location).toExcludeKey('key')
expect(Object.keys(location)).not.toContain('key')
})
})
})
6 changes: 3 additions & 3 deletions modules/__tests__/TestSequences/BackButtonTransitionHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export default (history, done) => {
let unblock, hookWasCalled = false
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

history.push('/home')
},
(location, action) => {
expect(action).toBe('PUSH')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})

Expand All @@ -25,7 +25,7 @@ export default (history, done) => {
},
(location, action) => {
expect(action).toBe('POP')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

Expand Down
4 changes: 2 additions & 2 deletions modules/__tests__/TestSequences/BlockEverything.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import execSteps from './execSteps'
export default (history, done) => {
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

const unblock = history.block()

history.push('/home')

expect(history.location).toMatch({
expect(history.location).toMatchObject({
pathname: '/'
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import expect from 'expect'

export default (history, done) => {
expect(history.location).toMatch({
expect(history.location).toMatchObject({
pathname: '/'
})

Expand Down
8 changes: 4 additions & 4 deletions modules/__tests__/TestSequences/DenyGoBack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export default (history, done) => {
let unblock
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

history.push('/home')
},
(location, action) => {
expect(action).toBe('PUSH')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})

unblock = history.block(nextLocation => {
expect(nextLocation).toMatch({
expect(nextLocation).toMatchObject({
pathname: '/'
})

Expand All @@ -29,7 +29,7 @@ export default (history, done) => {
},
(location, action) => {
expect(action).toBe('PUSH')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})

Expand Down
10 changes: 5 additions & 5 deletions modules/__tests__/TestSequences/DenyGoForward.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ export default (history, done) => {
let unblock
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

history.push('/home')
},
(location, action) => {
expect(action).toBe('PUSH')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})

history.goBack()
},
(location, action) => {
expect(action).toBe('POP')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

unblock = history.block(nextLocation => {
expect(nextLocation).toMatch({
expect(nextLocation).toMatchObject({
pathname: '/home'
})

Expand All @@ -37,7 +37,7 @@ export default (history, done) => {
},
(location, action) => {
expect(action).toBe('POP')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

Expand Down
6 changes: 3 additions & 3 deletions modules/__tests__/TestSequences/DenyPush.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import execSteps from './execSteps'
export default (history, done) => {
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

const unblock = history.block(nextLocation => {
expect(nextLocation).toMatch({
expect(nextLocation).toMatchObject({
pathname: '/home'
})

Expand All @@ -18,7 +18,7 @@ export default (history, done) => {

history.push('/home')

expect(history.location).toMatch({
expect(history.location).toMatchObject({
pathname: '/'
})

Expand Down
6 changes: 3 additions & 3 deletions modules/__tests__/TestSequences/EncodedReservedCharacters.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default (history, done) => {
history.replace(pathname)
},
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/view/%23abc'
})

Expand All @@ -18,7 +18,7 @@ export default (history, done) => {
history.replace({ pathname })
},
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/view/%23abc'
})
// unencoded string
Expand All @@ -27,7 +27,7 @@ export default (history, done) => {
}
,
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/view/',
hash: '#abc'
})
Expand Down
6 changes: 3 additions & 3 deletions modules/__tests__/TestSequences/GoBack.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import execSteps from './execSteps'
export default (history, done) => {
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

history.push('/home')
},
(location, action) => {
expect(action).toEqual('PUSH')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})

history.goBack()
},
(location, action) => {
expect(action).toEqual('POP')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})
}
Expand Down
8 changes: 4 additions & 4 deletions modules/__tests__/TestSequences/GoForward.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ import execSteps from './execSteps'
export default (history, done) => {
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

history.push('/home')
},
(location, action) => {
expect(action).toEqual('PUSH')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})

history.goBack()
},
(location, action) => {
expect(action).toEqual('POP')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

history.goForward()
},
(location, action) => {
expect(action).toEqual('POP')
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/home'
})
}
Expand Down
4 changes: 2 additions & 2 deletions modules/__tests__/TestSequences/HashChangeTransitionHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default (history, done) => {
let unblock, hookWasCalled = false
const steps = [
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/'
})

Expand All @@ -16,7 +16,7 @@ export default (history, done) => {
window.location.hash = 'something-new'
},
(location) => {
expect(location).toMatch({
expect(location).toMatchObject({
pathname: '/',
hash: '#something-new'
})
Expand Down
Loading