Commit aaf3278c authored by Wolfram Kriesing's avatar Wolfram Kriesing

First test for the fetch functionality.

Override the global fetch function, in order to be able to control the outcome of it.
parent ce657f84
const { assertThat, equalTo } = require('hamjest');
const { fetch } = require('./backend');
// const { fetch } = require('./backend');
let fetch;
const loadStudent = ({ studentId }, dependencies) => {
const cache = dependencies.cache;
......@@ -15,4 +16,10 @@ describe('Load a student', () => {
const student = loadStudent({ studentId: 42 }, dependencies);
assertThat(student, equalTo('student 42'));
});
it('fetch the student if not in the cache', () => {
let emptyCache = {};
fetch = () => 'student 23';
const student = loadStudent({ studentId: 23 }, { cache: emptyCache });
assertThat(student, equalTo('student 23'));
});
});
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