Skip to content

huhassan/react-redux-store-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project was bootstrapped with Create React App.

Coffee Store App

The App uses React and Redux

This application is an implementation of the Ice Cream Store App Demo by Thomas Tuts as part of the Redux in Motion Course on Manning Publications

Coure Objectives

  • The fundamentals of working with Redux
  • Writing maintainable code
  • Using Redux in the real-world
  • Handling asynchronous data
  • A test-first approach to web development
  • Combining React and Redux

Course Summary

Running Tests Using Jest

  • running a test using the it function
it('test name here', function() {
    expect(true).toEqual(true);
});
  • running multiple tests
describe('test group name', function() {
    it('first test', function() {
        expect(true).toEqual(true);
    });
    it('second test', function() {
        expect(true).toEqual(true);
    });    
});

Actions

  • basic action with an optional payload
const doSomething = (payloadValue = 'defaultPayloadValue') => ({
    type: 'DO_SOMETHING',
    payload: payloadValue
});

Reducers

  • reducer is a pure function that doesn't mutate the initial state
const initialState = {
    count: 0
}

function reducer(state = initialState, action) {
    switch (action.type) {
        case 'DO_SOMETHING',
            return {
                ...state,
                count: state.count + action.payload
            };
    }
}
});

Testing Reducers

import { action, reducer } from './dir/to/them';

describe('Counter', function () {
    it('should have an initial state', function () {
        const result = reducer();
        expect(result.count).toEqual(0);
    })
})

describe('Counter', function () {
    it('should increase by one', function () {
        const result = reducer();
        const action = actionCreator()
        expect(result.count).toEqual(1);
    })
})
});

About

Coffee Store Application that uses React and Redux.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published