-
-
Save zacck-zz/3365b9b624691c343df00af44e80f9a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Actions | |
Async supplier action tests | |
✖ should add a new supplier to firebase and dispatch ADD_SUPPLIER | |
Chrome 53.0.2785 (Mac OS X 10.11.6) | |
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>:76:43) | |
Async Tests | |
✖ "before each" hook for "should update a supplier in Firebase and dispatch UPDATE_SUPPLIER" | |
Chrome 53.0.2785 (Mac OS X 10.11.6) | |
Error: Fire/Users/zacck/Documents/www/jtx.set failed: First argument contains a function in property 'suppliers.-KSqFa8wmddwZOZ9b8MI.w.app.H.initializeApp' with contents: function (a,c){void 0===c?c="[DEFAULT]":"string"===typeof c&&""!==c||X("bad-app-name",{name:c+""});void 0!==b[c]&&X("dupApp",{name:c});var f=new Y(a,c,e);b[c]=f;d.forEach(function(a){return a("create",f)});void 0!=f.INTERNAL&&void 0!=f.INTERNAL.getToken||Q(f,{INTERNAL:{getToken:function(){return T.resolve(null)},addAuthTokenListener:function(){},removeAuthTokenListener:function(){}}});return f} | |
at Error (native) | |
at Bf (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:426:119) | |
at eval (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:427:166) | |
at Cb (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:345:627) | |
at Bf (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:426:424) | |
at eval (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:427:166) | |
at Cb (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:345:627) | |
at Bf (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:426:424) | |
at eval (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:427:166) | |
at Cb (eval at <anonymous> (/Users/zacck/Documents/www/jtx/app/tests/actions/actions.test.jsx:437:2), <anonymous>:345:627) |
This file contains hidden or 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 supplier action tests', () => { | |
var testSupplierRef; | |
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: '[email protected]', | |
telephone: '2797179', | |
website: 'ww.ww.ww', | |
category: 'cat', | |
rating: '100' | |
}; | |
it('should add a new supplier to firebase and dispatch ADD_SUPPLIER', (done) => { | |
const store = createMockStore({}); | |
//dispatch start supplier 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(() => { | |
const actions = store.getActions(); | |
expect(actions[0]).toInclude({ | |
type:'ADD_SUPPLIER', | |
testSupplier | |
}); | |
done(); | |
}).catch(done); | |
}); | |
describe('Async Tests', () => { | |
//add and remove from firebase before and after each test | |
beforeEach((done) => { | |
var suppliersRef = firebaseRef.child('suppliers'); | |
//wipe all suppliers | |
suppliersRef.remove().then(() => { | |
testSupplierRef = firebaseRef.child('suppliers').push(); | |
//load the payload | |
return testSupplierRef.set(testSupplierRef); | |
}).then(() => done()) | |
.catch(done); | |
}); | |
afterEach((done) => { | |
testSupplierRef.remove().then(() => done()); | |
}); | |
it('should update a supplier in Firebase and dispatch UPDATE_SUPPLIER', (done) => { | |
const store = createMockStore({}); | |
var updates = { | |
name:'Gotham City' | |
}; | |
const action = actions.startUpdateSupplier(testSupplierRef.key, updates); | |
store.dispatch(action).then(() => { | |
const mockactions = store.getActions(); | |
expect(mockactions[0]).toInclude({ | |
type: 'UPDATE_SUPPLIER', | |
id: testSupplierRef.key, | |
updates | |
}); | |
done(); | |
}, done()); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment