Jul 25, 2017 · 1 min read
Hi, good reading!
In the last example without stamps you bind the function:
export default function storeDocument(
{userID, folderLocation, fileStream}
) {const {resolveUserAccess, fileStorage} =
Object.assign({}, defaults, this); // this!!!return resolveUserAccess({userID, folderLocation})
.then(({user, folder}) =>
fileStorage.save(fileStream, {user, folder})
);
}.bind(defaults); // binding to the `default` context!!!
It exports storeDocument as a bounded function. Then you try to call it with different context:
storeDocument.call(
mockDependencies,
{userID, folderLocation, fileStream}
)which doesn’t work because storeDocument is already bounded to defaults, so mockDependencies are not accessible by this.
Am I missing something?
