add setting actions in content
This commit is contained in:
		
							parent
							
								
									7639e99b75
								
							
						
					
					
						commit
						c6eb5553d0
					
				
					 10 changed files with 74 additions and 25 deletions
				
			
		
							
								
								
									
										13
									
								
								test/content/actions/setting.test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								test/content/actions/setting.test.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
import { expect } from "chai";
 | 
			
		||||
import actions from 'content/actions';
 | 
			
		||||
import * as settingActions from 'content/actions/setting';
 | 
			
		||||
 | 
			
		||||
describe("setting actions", () => {
 | 
			
		||||
  describe("set", () => {
 | 
			
		||||
    it('create SETTING_SET action', () => {
 | 
			
		||||
      let action = settingActions.set({ red: 'apple', yellow: 'banana' });
 | 
			
		||||
      expect(action.type).to.equal(actions.SETTING_SET);
 | 
			
		||||
      expect(action.value).to.deep.equal({ red: 'apple', yellow: 'banana' });
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										18
									
								
								test/content/reducers/setting.test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/content/reducers/setting.test.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
import { expect } from "chai";
 | 
			
		||||
import actions from 'content/actions';
 | 
			
		||||
import settingReducer from 'content/reducers/setting';
 | 
			
		||||
 | 
			
		||||
describe("content setting reducer", () => {
 | 
			
		||||
  it('return the initial state', () => {
 | 
			
		||||
    let state = settingReducer(undefined, {});
 | 
			
		||||
    expect(state).to.deep.equal({});
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('return next state for SETTING_SET', () => {
 | 
			
		||||
    let newSettings = { red: 'apple', yellow: 'banana' };
 | 
			
		||||
    let action = { type: actions.SETTING_SET, value: newSettings };
 | 
			
		||||
    let state = settingReducer(undefined, action);
 | 
			
		||||
    expect(state).to.deep.equal(newSettings);
 | 
			
		||||
    expect(state).not.to.equal(newSettings);  // assert deep copy
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
		Reference in a new issue