Created
April 20, 2018 09:17
-
-
Save innerdaze/23880eac0b3444b5efdd9d30e5c35258 to your computer and use it in GitHub Desktop.
Example Selector Unit Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configureMockStore from 'redux-mock-store' | |
import thunk from 'redux-thunk' | |
import * as selectors from '../selectors' | |
const middlewares = [thunk] | |
const mockStore = configureMockStore(middlewares) | |
describe('INVENTORY/SELECTORS', () => { | |
test('barcode to product lookup works', () => { | |
const mockProduct = { | |
ProductID: 'ABC' | |
} | |
const store = mockStore({ | |
product: { | |
productEntities: { | |
ABC: mockProduct | |
} | |
}, | |
barcode: { | |
barcodeEntities: { | |
1234: { | |
Barcode: 1234, | |
ProductID: 'ABC' | |
} | |
} | |
} | |
}) | |
const product = selectors.productByBarcodeSelector(store.getState(), 1234) | |
expect(product).toEqual(mockProduct) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment