Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jest test thunk

import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
const middlewares = [thunk]
const mockStore = configureMockStore(middleware)

describe('async actions', () => {
    
  it('should dispatch actions of ConstantA and ConstantB', () => {
    const expectedActions = [
      {type: CONSTANT_A, payload: 'a'},
      {type: CONSTANT_B, payload: 'b'} 
    ]

    const store = mockStore({ yourInitialState })
    store.dispatch(actions.functionA('a', 'b'))

    expect(store.getActions()).toEqual(expectedActions)
  })
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: line break in javascript in notification 
Javascript :: recursive function scheme 
Javascript :: alpinjs 
Javascript :: Get position of each element using jquery 
Javascript :: js if the reverse of a number is better than the original num 
Javascript :: avoid compressing imagepicker react native 
Javascript :: express routers 
Javascript :: repeat call n times in js 
Javascript :: js backwards loop 
Javascript :: scrape html table javascript 
Javascript :: postfix date javascript 
Javascript :: find outlier js 
Javascript :: execcommand image 
Javascript :: snackbar in react 
Javascript :: Select First Element querySelector 
Javascript :: what is console in javascript 
Javascript :: Swap a select text with javascript 
Javascript :: get value from serialized json apex 
Javascript :: remove last element from an array 
Javascript :: how to get max value from array of objects in javascript 
Javascript :: how to give index in query selector in js 
Javascript :: how to add row in angular dynamically 
Javascript :: sending api request in axios with files 
Javascript :: get all data in collection firebase react 
Javascript :: alert message 
Javascript :: bash json creator 
Javascript :: Resize Image Using HTML Canvas in JavaScript 
Javascript :: remove elemtns from an array with splice 
Javascript :: register service worker 
Javascript :: super in javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =