diff --git a/test/helpers/appUtils.test.js b/test/helpers/appUtils.test.js index 20478496..97fd61ef 100644 --- a/test/helpers/appUtils.test.js +++ b/test/helpers/appUtils.test.js @@ -2,6 +2,7 @@ const path = require('path'); const { parsePatientIds } = require('../../src/helpers/appUtils'); const MOCK_VALID_ID_CSV = path.join(__dirname, './fixtures/valid-mrns.csv'); +const MOCK_VALID_ID_CSV_WITH_BOM = path.join(__dirname, './fixtures/valid-mrns-bom.csv'); // Has no MRN column const MOCK_INVALID_ID_CSV = path.join(__dirname, './fixtures/invalid-mrns.csv'); @@ -17,6 +18,15 @@ describe('appUtils', () => { expect(ids).toEqual(expectedIds); }); + test('valid path to CSV with BOM should parse content', () => { + const expectedIds = ['123', '456', '789']; + const ids = parsePatientIds(MOCK_VALID_ID_CSV_WITH_BOM); + + // Should get every MRN and correctly parse with BOM + expect(ids).toHaveLength(expectedIds.length); + expect(ids).toEqual(expectedIds); + }); + test('invalid path should throw error', () => { expect(() => parsePatientIds(MOCK_INVALID_ID_CSV)).toThrowError(); }); diff --git a/test/helpers/fixtures/valid-mrns-bom.csv b/test/helpers/fixtures/valid-mrns-bom.csv new file mode 100644 index 00000000..f2b8d155 --- /dev/null +++ b/test/helpers/fixtures/valid-mrns-bom.csv @@ -0,0 +1,4 @@ +mrn +123 +456 +789