From 6de733c073effae9716a8fd3accc085b9bff5043 Mon Sep 17 00:00:00 2001 From: kairi1227 Date: Mon, 12 Mar 2018 10:45:25 +0800 Subject: [PATCH] update test --- tests/components/Example.test.js | 1 + tests/models/login.test.js | 37 ++++++++++++++++++++++++++++++++ tests/utils/validator.test.js | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/models/login.test.js diff --git a/tests/components/Example.test.js b/tests/components/Example.test.js index 6dc550b..84c02d6 100644 --- a/tests/components/Example.test.js +++ b/tests/components/Example.test.js @@ -1,4 +1,5 @@ import React from 'react'; +import 'raf/polyfill'; import { shallow } from 'enzyme'; import Example from '../../src/components/Example'; diff --git a/tests/models/login.test.js b/tests/models/login.test.js new file mode 100644 index 0000000..60fcf7b --- /dev/null +++ b/tests/models/login.test.js @@ -0,0 +1,37 @@ +import 'babel-polyfill'; +import 'raf/polyfill'; +import React from 'react'; +import chai from 'chai'; +import LoginModel from '../../src/models/login'; + +describe('models/login', () => { + describe('test namespace', () => { + it('The namespace validate for this model:', () => { + chai.expect(LoginModel.namespace).to.equals('login'); + }); + }); + describe('test states', () => { + it('validate initial state.', () => { + chai.expect(LoginModel.state).to.be.an('object').that.have.property('changeLoginStatus'); + chai.expect(LoginModel.state).to.deep.equals({ + changeLoginStatus: {}, + user: [] + }); + }); + }); + + describe('test reducers', () => { + it('validate reducer function:', () => { + chai.expect(LoginModel.reducers).to.be.an('object').that.have.property('setState'); + chai.expect(LoginModel.reducers.setState({}, {payload: {test: {}}})).to.deep.equals({test: {}}); + }); + }); + + describe('test effects', function() { + it('validate effects function:', function() { + chai.expect(LoginModel.effects).to.be.an('object').that.have.property('accountSubmit'); + const accountSubmit = LoginModel.effects.accountSubmit; + yield accountSubmit({payload: {username: '8888'}}) + }); + }); +}); diff --git a/tests/utils/validator.test.js b/tests/utils/validator.test.js index f6c3c61..2ff749b 100644 --- a/tests/utils/validator.test.js +++ b/tests/utils/validator.test.js @@ -1,4 +1,4 @@ -import 'babel-polyfill'; +import 'raf/polyfill'; import {checkUsername} from '../../src/utils/validator'; import chai from 'chai'; const {expect} = chai;