From 71eca36c639ff80930dd8b16f653b731d593b22b Mon Sep 17 00:00:00 2001 From: dakota002 Date: Wed, 20 Nov 2024 10:34:52 -0500 Subject: [PATCH] Adds EP pattern and tests --- __tests__/circulars.ts | 48 +++++++++++++++++++++++++++ app/routes/circulars/circulars.lib.ts | 1 + 2 files changed, 49 insertions(+) diff --git a/__tests__/circulars.ts b/__tests__/circulars.ts index 5300e3d13..58aaf873f 100644 --- a/__tests__/circulars.ts +++ b/__tests__/circulars.ts @@ -71,6 +71,7 @@ describe('parseEventFromSubject', () => { const lvkEvent = 'LIGO/Virgo S200224ca' const sgrEvent = 'SGR 1935+2154' const ztfEvent = 'ZTF23aabmzlp' + const epEvent = 'EP241119a' test('handles nonsense subject cases', () => { expect(parseEventFromSubject('zawxdrcftvgbhnjm')).toBe(undefined) @@ -230,6 +231,53 @@ describe('parseEventFromSubject', () => { }) }) + describe('EP', () => { + test('handles EP event names with space', () => { + const epSubject = 'EP 241119a: Global MASTER-Net observations report' + expect(parseEventFromSubject(epSubject)).toBe(epEvent) + }) + + test('handles EP event names with space in misc positions', () => { + const epSubjectWithSpace = + 'Global MASTER-Net EP 241119a observations report' + expect(parseEventFromSubject(epSubjectWithSpace)).toBe(epEvent) + }) + + test('handles EP event names without space', () => { + const epSubjectWithNoSpace = 'EP241119a EP detection' + expect(parseEventFromSubject(epSubjectWithNoSpace)).toBe(epEvent) + }) + + test('handles EP event names without spaces in misc positions', () => { + const epSubjectWithSpace = 'EP detection of EP241119a GRB' + expect(parseEventFromSubject(epSubjectWithSpace)).toBe(epEvent) + }) + + test('handles EP event name with an underscore', () => { + const epSubjectWithUnderscore = + 'EP_241119a: Global MASTER-Net observations report' + expect(parseEventFromSubject(epSubjectWithUnderscore)).toBe(epEvent) + }) + + test('handles EP event names with an underscore in misc positions', () => { + const epSubjectWithUnderscore = + 'Global MASTER-Net EP_241119a observations report' + expect(parseEventFromSubject(epSubjectWithUnderscore)).toBe(epEvent) + }) + + test('handles EP event name with a hyphen', () => { + const epSubjectWithHyphen = + 'EP-241119a: Global MASTER-Net observations report' + expect(parseEventFromSubject(epSubjectWithHyphen)).toBe(epEvent) + }) + + test('handles EP event name with a hyphen in misc positions', () => { + const epSubjectWithHyphen = + 'Global MASTER-Net EP-241119a observations report' + expect(parseEventFromSubject(epSubjectWithHyphen)).toBe(epEvent) + }) + }) + describe('ZTF', () => { test('handles ZTF event names with space', () => { const ztfSubject = diff --git a/app/routes/circulars/circulars.lib.ts b/app/routes/circulars/circulars.lib.ts index a23c9a10e..69dd51abd 100644 --- a/app/routes/circulars/circulars.lib.ts +++ b/app/routes/circulars/circulars.lib.ts @@ -70,6 +70,7 @@ const subjectMatchers: SubjectMatcher[] = [ /Baksan\sNeutrino\sObservatory\sAlert[.\s_-]*(\d{6}.\d{2})/i, ([, id]) => `Baksan Neutrino Observatory Alert ${id}`, ], + [/EP[.\s_-]*(\d{6}[a-z])/i, ([, id]) => `EP${id}`], ] /** Format a Circular as plain text. */