Commit ce657f84 by Wolfram Kriesing

Make dependency more explicit by not destructuring it.

parent a17fec97
const { assertThat, equalTo } = require('hamjest');
const { fetch } = require('./backend');
const loadStudent = ({ studentId }, { cache }) => {
const loadStudent = ({ studentId }, dependencies) => {
const cache = dependencies.cache;
if (!cache[studentId]) {
cache[studentId] = fetch({ studentId });
}
......@@ -10,8 +11,8 @@ const loadStudent = ({ studentId }, { cache }) => {
describe('Load a student', () => {
it('from the cache', () => {
const cache = { 42: 'student 42' }; // <<< no more globals :)
const student = loadStudent({ studentId: 42 }, { cache });
let dependencies = { cache: { 42: 'student 42' } };
const student = loadStudent({ studentId: 42 }, dependencies);
assertThat(student, equalTo('student 42'));
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment