Testing our plugin
Tsdx creates all the configuration we need to make our tests with Jest out of the box. As you'll remember, we used this testing framework for our Amazhop application. We'll just use the same approach.
Inside our index.test.ts
file, we can add a describe()
function that describes what we are going to test:
describe("Rematch Plugin Typed State", () => {})
Since we're going to use the same model in every test, we can create a constant to extend a base model for each test:
const BASE_MODEL = { name: 'user', state: { name: "Sergio", age: 23, }, reducers: { update: (_, { name, age }) => ({ name, age, }), }, };
This code is a basic Rematch model, a state with one string and one number...