build.spec.js 657 B

1234567891011121314151617
  1. import fs from 'fs';
  2. import expect from 'expect';
  3. import {build as buildXSLX} from './../../src';
  4. describe('node-xlsx builder', () => {
  5. it('should throw if no input is given', () => {
  6. expect(() => buildXSLX()).toThrow();
  7. });
  8. it('should properly build an XLSX from ', () => {
  9. const expected = fs.readFileSync(`${__dirname}/../fixtures/test.xlsx`);
  10. const worksheets = JSON.parse(fs.readFileSync(`${__dirname}/../fixtures/test.json`));
  11. const result = buildXSLX(worksheets);
  12. expect(result instanceof Buffer).toBeTruthy();
  13. // Only check the ten first bytes
  14. expect(result.slice(0, 10)).toEqual(expected.slice(0, 10));
  15. });
  16. });