I have a test where I'm trying to test the construction of an api call. I am trying to mock the api and am wondering how to access nested objects with sinon.
it('should create the correct fetch method', (done) => {
let mock = { shop: {get: (...args) => true } };
let api = sinon.mock(mock);
let file = sinon.spy();
let endpoint = 'shop.get';
let args = {optionA: 'a', optionB: 'b'};
api.expects(endpoint).withArgs(...args); // throws error
fetch.call(api, endpoint, file, ...args)
.then(() => {
api.verify();
done();
});
});
I'm getting this type error: TypeError: Attempted to wrap object property shop as function
Aucun commentaire:
Enregistrer un commentaire