From 0c9b9aa3eab9d0204c60cd0e59b5dd3526001334 Mon Sep 17 00:00:00 2001 From: Julia Afeltra Date: Tue, 15 Jun 2021 15:16:01 -0400 Subject: [PATCH] Add test for parsing patient id MRN with BOM --- test/helpers/appUtils.test.js | 10 ++++++++++ test/helpers/fixtures/valid-mrns-bom.csv | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 test/helpers/fixtures/valid-mrns-bom.csv 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