Skip to content

Commit

Permalink
Lint:fix & format
Browse files Browse the repository at this point in the history
  • Loading branch information
Siemienik committed Oct 24, 2021
1 parent be49152 commit 26007a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/xlsx-import/src/ImporterFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Buffer, Workbook} from 'exceljs';
import { Buffer, Workbook } from 'exceljs';
import { IImporter } from './IImporter';
import ImporterLegacy, { Importer } from './Importer';

Expand All @@ -9,10 +9,10 @@ export class ImporterFactory {
return new Importer(wb);
}

public async fromBuffer(buffer: Buffer): Promise<IImporter>{
public async fromBuffer(buffer: Buffer): Promise<IImporter> {
const wb = new Workbook();
await wb.xlsx.load(buffer);
return new Importer(wb)
return new Importer(wb);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/xlsx-import/src/mappers/dateMapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueMapper } from '../abstracts/ValueMapper';

// noinspection SuspiciousTypeOfGuard
export const dateMapper: ValueMapper<Date> = value => new Date(typeof value === "string" ? value : "invalid");
export const dateMapper: ValueMapper<Date> = value => new Date(typeof value === 'string' ? value : 'invalid');
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as chai from 'chai';
import { ImportType } from '../../src/config/ImportType';
import { ImporterFactory } from '../../src/ImporterFactory';
import path from "path";
import {readFileSync} from 'fs'

import path from 'path';
import { readFileSync } from 'fs';

describe('reading sigle items (objects)', () => {
const configs = {
Expand All @@ -30,10 +29,10 @@ describe('reading sigle items (objects)', () => {
});
it('getAllItems should return one correct object from buffer', async () => {
const factory = new ImporterFactory();
const filePath = path.resolve(__dirname, '../data/','marsjanie-db.xlsx')
const buffer = readFileSync(filePath)
const filePath = path.resolve(__dirname, '../data/', 'marsjanie-db.xlsx');
const buffer = readFileSync(filePath);
const importer = await factory.fromBuffer(buffer);
const result = importer.getAllItems(configs.author)
const result = importer.getAllItems(configs.author);

const expected = [{ firstName: 'Marian', secondName: 'Marianacki', age: 123, city: 'Pila-wojenna' }];

Expand Down
5 changes: 4 additions & 1 deletion packages/xlsx-import/tests/unit/mappers/dateMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ describe('UNIT TEST: src/mappers/', () => {
describe('dateMapper', () => {
const dataProvider = [
// data time
{ inValue: 'Thu Oct 08 2020 02:00:00 GMT+0200 (Central European Summer Time)', expectedResult: 1602115200000 },
{
inValue: 'Thu Oct 08 2020 02:00:00 GMT+0200 (Central European Summer Time)',
expectedResult: 1602115200000,
},
{ inValue: 'Thu Jan 30 1750 02:00:00 GMT-0900', expectedResult: -6939954000000 },
{ inValue: 'Thu Jan 30 3125', expectedResult: 36450774000000 },

Expand Down

0 comments on commit 26007a8

Please sign in to comment.