Created
October 4, 2016 07:48
-
-
Save zacck-zz/3118600730813eaeacdcdfa5e3b3b5df to your computer and use it in GitHub Desktop.
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
FAILED TESTS: | |
Actions | |
Supplier Actions | |
Async Actions | |
✖ should upload supplier and dispatch ADD_SUPPLIER | |
Chrome 53.0.2785 (Mac OS X 10.12.0) | |
Error: The "actual" argument in expect(actual).toInclude() must be an array or a string | |
at Object.assert [as default] (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:1230:2), <anonymous>:20:9) | |
at Expectation.toInclude (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:1128:2), <anonymous>:180:24) | |
at eval (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:47:2), <anonymous>:129:45) | |
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
describe('Async Actions', () => { | |
it('should upload supplier and dispatch ADD_SUPPLIER', (done)=> { /*Let Mocha know that this is asnyc test*/ | |
//mock a store | |
const store = createMockStore({}); | |
//test supplier | |
var testSupplier = { | |
name: 'new supplier', | |
fact_sheet: 'fact sheet', | |
liability_sheet: 'liability sheet', | |
group: 'group', | |
service_lines: null, | |
policies: null, | |
rate_periods: null, | |
rate_costs: null, | |
contracts: null, | |
cancellation_terms: null, | |
deposit_terms: null, | |
commission: '22', | |
creation_date: moment().unix(), | |
country: 'SA', | |
region: 'Capetown', | |
email: 'mail@m.com', | |
telephone: '2797179', | |
website: 'ww.ww.ww', | |
category: 'cat', | |
rating: '100' | |
}; | |
//Do the async action | |
store.dispatch(actions.startAddSupplier(testSupplier.name, testSupplier.fact_sheet, testSupplier.liability_sheet, testSupplier.group, | |
testSupplier.commission, testSupplier.country, testSupplier.region, testSupplier.email, testSupplier.telephone, testSupplier.website, testSupplier.category, testSupplier.rating)).then( | |
() => { | |
/*Assertions*/ | |
const actions = store.getActions(); //returns array of all actions fired on store | |
expect(actions[0]).toInclude({ | |
type: 'ADD_SUPPLIER', | |
supplier: testSupplier | |
}); | |
// expect(actions[0].supplier).toInclude({ | |
// category: 'cat' | |
// }); | |
/*done to show test is done*/ | |
done(); | |
}).catch(done);//if done is called with args it is assumed the test has failed | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment