Skip to content

Commit

Permalink
[PT#149710069] Added snapshot tests for App
Browse files Browse the repository at this point in the history
  • Loading branch information
kylane committed Aug 9, 2017
1 parent 57dc418 commit 2c47280
Show file tree
Hide file tree
Showing 4 changed files with 705 additions and 9 deletions.
94 changes: 94 additions & 0 deletions src/modules/App/components/App.snapshot.test.js
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();
});

});
Loading

0 comments on commit 2c47280

Please sign in to comment.