Last but not least, let's take a look at the image controller, and specifically test for the main index function. Since the index function does a lot of work and performs a number of different tasks, the test file will make extensive use of stubs and spies. The first thing we need to do before any tests is declare a number of global variables for our tests, as well as set up all of our stubs, spies, and placeholder objects for use with proxyquire. Then, we require the actual image controller using proxyquire. Create a file named tests/controllers/image.test.js and insert the following code:
let proxyquire = require('proxyquire'), callback = sinon.spy(), sidebarStub = sinon.stub(), fsStub = {}, pathStub = {}, md5Stub ...