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
// The information of the person you want to add | |
// Please note that they key has to match the wait the field is defined in your spreadsheet. | |
// The person table is linked to the Countries table. A person can have more than one country so you pass an array of all the countries Ids that the user belongs to. | |
const newPersonInfo = { | |
"First name": "Fatimat", | |
"Last Name": "Badmus", | |
Countries: ["recWWTmP55RDo2Abu"] | |
}; | |
const createRecord = () => |
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 deepFreeze from "deep-freeze"; | |
//importing deep-freeze, an npm module which helps to make sure I am not mutating state as that is the rule for a reducer | |
describe("Alert reducer", () => { | |
it("Adds an error", () => { | |
const initialState = { | |
type:"", | |
message:"" | |
}; | |
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 { mockStore, mockAxios } from "../test-support"; | |
//importing our helper variables previously defined in setup stage. | |
describe("Logout action", () => { | |
it("Returns the correct action to log out a user", () => { | |
const mockLogout = () => mockAxios.onGet("/api/logout").reply(200); | |
//I am creating a mock log out function using the mockAxios variable which by default has access to methods built in to the module. | |
//I am using the onGet method to call our api. Notice how the string I pass in, is the same as the string I pass in to my axios.get method in my real logout function. It is important that it is the same. | |
//The reply method is checking to make sure my request is going through hence why I am passing in the status code 200. |
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 thunk from "redux-thunk"; | |
// redux-thunk middleware is what I use in development stage to handle my asynchronous actions. | |
import configureStore from "redux-mock-store"; | |
// redux-mock-store is a mock(fake copy) store for testing Redux async action creators and middleware. | |
//The mock store will create an array of dispatched actions which serve as an action log for tests. | |
import axios from "axios"; | |
//axios is a promised based module for creating HTTP requests I am using. |