Skip to content

Commit

Permalink
Add jest/enzyme and a simple unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sepans committed Jan 25, 2019
1 parent 772a7c9 commit e1ef323
Show file tree
Hide file tree
Showing 7 changed files with 20,234 additions and 7,797 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"env": {
"browser": true,
"node": true,
"mocha": true
"jest": true
},
"rules": {
"linebreak-style": 0,
Expand Down
1 change: 1 addition & 0 deletions client/__test__/mocks/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
47 changes: 47 additions & 0 deletions client/components/__test__/Nav.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

import React from 'react';
import { shallow } from 'enzyme';

import Nav from './../Nav';

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(),
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()
};
const getWrapper = () => shallow(<Nav {...props} />);

test('it renders main navigation', () => {
const nav = getWrapper();
expect(nav.exists('.nav')).toEqual(true);
});
});
3 changes: 3 additions & 0 deletions developer_docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Follow these instructions to set up your development environment, which you need
11. Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
12. Open and close the Redux DevTools using `ctrl+h`, and move them with `ctrl+w`

## Tests (in progress)
Run `npm test`

## Docker Installation

Using Docker, you can have a complete, consistent development environment without having to manually install dependencies such as Node, Mongo, etc. It also helps isolate these dependencies and their data from other projects that you may have on the same computer that use different/conflicting versions, etc.
Expand Down
4 changes: 4 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

configure({ adapter: new Adapter() })
Loading

0 comments on commit e1ef323

Please sign in to comment.