const assert = require('assert');
const proxyquire = require('proxyquire');
const sinon = require('sinon');

const fsMock = {};
const main = proxyquire('./index', { 'fs': fsMock });

describe('main.writeFile', () => {
    it('should write a trimmed string to the specified file', () => {
        fsMock.writeFileSync = sinon.spy();
        main.writeFile('foo.txt', 'stuff ');
        assert.deepEqual(fsMock.writeFileSync.getCall(0).args, [
            'foo.txt',
            'stuff',
            'utf8',
        ]);
    });
});
const fs = require('fs');

exports.writeFile = (filename, contents) => {
    fs.writeFileSync(filename, contents.trim(), 'utf8');
};