Skip to content

Commit

Permalink
Adds EP pattern and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dakota002 authored and lpsinger committed Nov 20, 2024
1 parent 00751c7 commit 71eca36
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions __tests__/circulars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions app/routes/circulars/circulars.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 71eca36

Please sign in to comment.