-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated tests for import services and util files
- Loading branch information
Showing
10 changed files
with
216 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
272 changes: 127 additions & 145 deletions
272
api/src/services/import-services/critter/import-critters-service.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { expect } from 'chai'; | ||
import { | ||
generateCellGetterFromColumnValidator, | ||
getColumnAliasesFromValidator, | ||
getColumnNamesFromValidator | ||
} from './column-validator-utils'; | ||
import { IXLSXCSVValidator } from './worksheet-utils'; | ||
|
||
const columnValidator = { | ||
NAME: { type: 'string' }, | ||
ID: { type: 'number', aliases: ['IDENTIFIER'] }, | ||
AGE: { type: 'number' }, | ||
BIRTH_DATE: { type: 'date' } | ||
} satisfies IXLSXCSVValidator; | ||
|
||
describe.only('column-validator-utils', () => { | ||
describe('getColumnNamesFromValidator', () => { | ||
it('should return all column names from validator', () => { | ||
expect(getColumnNamesFromValidator(columnValidator)).to.be.eql(['NAME', 'ID', 'AGE', 'BIRTH_DATE']); | ||
}); | ||
}); | ||
|
||
describe('getColumnAliasesFromValidator', () => { | ||
it('should return all column aliases from validator', () => { | ||
expect(getColumnAliasesFromValidator(columnValidator)).to.be.eql(['IDENTIFIER']); | ||
}); | ||
}); | ||
|
||
describe('generateCellGetterFromColumnValidator', () => { | ||
const getCellValue = generateCellGetterFromColumnValidator(columnValidator); | ||
|
||
it('should return the cell value for a known column name', () => { | ||
expect(getCellValue({ NAME: 'Dr. Steve Brule' }, 'NAME')).to.be.eql('Dr. Steve Brule'); | ||
}); | ||
|
||
it('should return the cell value for a known alias name', () => { | ||
expect(getCellValue({ IDENTIFIER: 1 }, 'ID')).to.be.eql(1); | ||
}); | ||
|
||
it('should return undefined if row cannot find cell value', () => { | ||
expect(getCellValue({ BAD_NAME: 1 }, 'NAME')).to.be.eql(undefined); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters