Skip to content

Commit

Permalink
Add identity-obj-proxy, write fetchEvents test
Browse files Browse the repository at this point in the history
- to mock css module for react-big-calendar

Co-authored-by: name <[email protected]>
  • Loading branch information
2 people authored and joaopapereira committed Feb 22, 2019
1 parent 5564587 commit 3745145
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module.exports = {
'<rootDir>/cypress/',
'<rootDir>/node_modules/'
],
'moduleNameMapper': {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy'
},
'transform': {
'^.+\\.js$': 'babel-jest',
'.+\\.(css|styl|less|sass|scss)$': 'jest-transform-css',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"eslint-plugin-react-hooks": "^1.0.1",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^23.6.0",
"jest-transform-css": "^2.0.0",
"mini-css-extract-plugin": "^0.5.0",
Expand Down
22 changes: 22 additions & 0 deletions src/tests/containers/EventsList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { mount } from 'enzyme'
import { EventsList } from '../../containers/EventsList'

describe('Events List', () => {
let wrapper
const props = {
events: [],
fetchEvents: jest.fn()
}
beforeEach(() => {
wrapper = mount(<EventsList {...props} />)
})

it('calls fetchEvents when eventsList is empty', () => {
expect(props.fetchEvents).toBeCalledTimes(1)
})

it('displays a calendar for events', () => {
expect(wrapper.find('Calendar')).toHaveLength(1)
})
})
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5409,6 +5409,11 @@ har-validator@~5.1.0:
ajv "^6.5.5"
har-schema "^2.0.0"

harmony-reflect@^1.4.6:
version "1.6.1"
resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.6.1.tgz#c108d4f2bb451efef7a37861fdbdae72c9bdefa9"
integrity sha512-WJTeyp0JzGtHcuMsi7rw2VwtkvLa+JyfEKJCFyfcS0+CDkjQ5lHPu7zEhFZP+PDSRrEgXa5Ah0l1MbgbE41XjA==

has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
Expand Down Expand Up @@ -5724,6 +5729,13 @@ icss-utils@^4.0.0:
dependencies:
postcss "^7.0.5"

identity-obj-proxy@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14"
integrity sha1-lNK9qWCERT7zb7xarsN+D3nx/BQ=
dependencies:
harmony-reflect "^1.4.6"

ieee754@^1.1.4:
version "1.1.12"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b"
Expand Down

0 comments on commit 3745145

Please sign in to comment.