p5.js-web-editor/client/components/__test__/Nav.test.jsx

63 lines
1.4 KiB
React
Raw Normal View History

2018-10-27 23:22:54 +00:00
import React from 'react';
import { shallow } from 'enzyme';
2018-10-28 00:48:57 +00:00
import renderer from 'react-test-renderer';
2018-10-27 23:22:54 +00:00
2019-02-10 00:45:29 +00:00
import { NavComponent } from './../Nav';
2018-10-27 23:22:54 +00:00
describe('Nav', () => {
const props = {
newProject: jest.fn(),
saveProject: jest.fn(),
autosaveProject: jest.fn(),
exportProjectAsZip: jest.fn(),
cloneProject: jest.fn(),
user: {
authenticated: true,
username: 'new-user',
id: 'new-user'
},
project: {
id: 'new-project',
owner: {
id: 'new-user'
}
},
logoutUser: jest.fn(),
2019-02-10 00:45:29 +00:00
newFile: jest.fn(),
newFolder: jest.fn(),
2018-10-27 23:22:54 +00:00
showShareModal: jest.fn(),
showErrorModal: jest.fn(),
unsavedChanges: false,
warnIfUnsavedChanges: jest.fn(),
showKeyboardShortcutModal: jest.fn(),
cmController: {
tidyCode: jest.fn(),
showFind: jest.fn(),
findNext: jest.fn(),
findPrev: jest.fn()
},
startSketch: jest.fn(),
stopSketch: jest.fn(),
setAllAccessibleOutput: jest.fn(),
showToast: jest.fn(),
setToastText: jest.fn(),
rootFile: {
id: 'root-file'
}
2018-10-27 23:22:54 +00:00
};
2019-02-10 00:45:29 +00:00
const getWrapper = () => shallow(<NavComponent {...props} />);
2018-10-27 23:22:54 +00:00
test('it renders main navigation', () => {
const nav = getWrapper();
expect(nav.exists('.nav')).toEqual(true);
});
2018-10-28 00:48:57 +00:00
it('renders correctly', () => {
const tree = renderer
2019-02-10 00:45:29 +00:00
.create(<NavComponent {...props} />)
2018-10-28 00:48:57 +00:00
.toJSON();
expect(tree).toMatchSnapshot();
});
2018-10-27 23:22:54 +00:00
});