mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 01:37:24 +03:00
Created App test
This commit is contained in:
parent
933de6e2c5
commit
3d39fa724c
2 changed files with 36 additions and 2 deletions
|
@ -15,6 +15,14 @@ export class Storage {
|
|||
set = (key, value) => this.localStorage.setItem(buildPath(key), JSON.stringify(value));
|
||||
}
|
||||
|
||||
const storage = typeof localStorage !== 'undefined' ? localStorage : {};
|
||||
const browserStorage = global.localStorage || {
|
||||
getItem() {
|
||||
return '';
|
||||
},
|
||||
setItem() {
|
||||
return '';
|
||||
},
|
||||
};
|
||||
const storage = new Storage(browserStorage);
|
||||
|
||||
export default new Storage(storage);
|
||||
export default storage;
|
||||
|
|
26
test/App.test.js
Normal file
26
test/App.test.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Route } from 'react-router-dom';
|
||||
import App from '../src/App';
|
||||
import MainHeader from '../src/common/MainHeader';
|
||||
|
||||
describe('<App />', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<App />);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
||||
it('renders a header', () => expect(wrapper.find(MainHeader)).toHaveLength(1));
|
||||
|
||||
it('renders app main routes', () => {
|
||||
const routes = wrapper.find(Route);
|
||||
const expectedRoutesCount = 3;
|
||||
|
||||
expect(routes).toHaveLength(expectedRoutesCount);
|
||||
expect(routes.at(0).prop('path')).toEqual('/server/create');
|
||||
expect(routes.at(1).prop('path')).toEqual('/');
|
||||
expect(routes.at(2).prop('path')).toEqual('/server/:serverId');
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue