forked from uqlibrary/fez-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PT#149710069] Added snapshot tests for App
- Loading branch information
Showing
4 changed files
with
705 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//jest.dontMock('./App'); | ||
|
||
import {shallow} from 'enzyme'; | ||
import toJson from 'enzyme-to-json'; | ||
import React from 'react'; | ||
|
||
import App from './App'; | ||
import {accounts} from '../../../mock/data/account'; | ||
import {authorDetails} from '../../../mock/data/authors'; | ||
|
||
function setup(values) { | ||
return shallow(<App {...values} />); | ||
} | ||
|
||
window.matchMedia = window.matchMedia || function () { | ||
return { | ||
matches: false, | ||
addListener: function () { | ||
}, | ||
removeListener: function () { | ||
} | ||
}; | ||
}; | ||
|
||
describe('App tests for user account and author status', () => { | ||
it('User logged in and is an author)', () => { | ||
const values = { | ||
user: { | ||
account: {...accounts.uqstaff}, | ||
authorDetailsLoading: false, | ||
accountLoading: false, | ||
authorDetails: {...authorDetails.uqresearcher} | ||
}, | ||
location: { | ||
hash: '#/dashboard', | ||
pathname: '/', | ||
} | ||
}; | ||
const wrapper = setup(values); | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
it('User logged in but is not an author)', () => { | ||
const values = { | ||
user: { | ||
account: {...accounts.uqstaff}, | ||
authorDetailsLoading: false, | ||
accountLoading: false, | ||
authorDetails: null, | ||
}, | ||
location: { | ||
hash: '#/dashboard', | ||
pathname: '/', | ||
} | ||
}; | ||
const wrapper = setup(values); | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
it('User is not logged in and is not an author)', () => { | ||
const values = { | ||
user: { | ||
account: null, | ||
authorDetailsLoading: false, | ||
accountLoading: false, | ||
authorDetails: null, | ||
}, | ||
location: { | ||
hash: '#/dashboard', | ||
pathname: '/', | ||
} | ||
}; | ||
const wrapper = setup(values); | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
it('User is logged in but are still loading authorDetails)', () => { | ||
const values = { | ||
user: { | ||
account: {...accounts.uqstaff}, | ||
authorDetailsLoading: true, | ||
accountLoading: false, | ||
authorDetails: null, | ||
}, | ||
location: { | ||
hash: '#/dashboard', | ||
pathname: '/', | ||
} | ||
}; | ||
const wrapper = setup(values); | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
}); |
Oops, something went wrong.