Commit a17fec97 authored by Wolfram Kriesing's avatar Wolfram Kriesing

Separate dependency from function parameter.

parent 2c485ba3
const { assertThat, equalTo } = require('hamjest');
const { fetch } = require('./backend');
const loadStudent = ({ studentId, cache }) => {
const loadStudent = ({ studentId }, { cache }) => {
if (!cache[studentId]) {
cache[studentId] = fetch({ studentId });
}
......@@ -11,7 +11,7 @@ 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 });
const student = loadStudent({ studentId: 42 }, { cache });
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