Skip to content

Commit

Permalink
better nation matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Jul 5, 2024
1 parent 6de04ec commit a244b56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/api/squaremap/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ export const parseTooltip = (tooltip: string) => {

const out: ParsedTooltip = { town }

const nationMatch = cleaned.match(/\(.* of ([A-Za-z\u00C0-\u017F]+)\)/)
const nationMatch = cleaned.match(/\((?:.* of )?([A-Za-z\u00C0-\u017F_]+)\)/)
const nation = nationMatch ? nationMatch[1] : null

if (nation) out['nation'] = nation

const indexClosingBracket = cleaned.indexOf(')')
Expand Down
7 changes: 5 additions & 2 deletions tests/squaremap/nations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ describe('[Squaremap/Aurora] Nations', () => {
})

it('can get single nation', async () => {
const nation = await Aurora.Nations.get('madagascar') as Nation
const nation = await Aurora.Nations.get('great_bulgaria')

expect(nation).toBeTruthy()
expectTypeOf(nation).not.toEqualTypeOf<Error>

//@ts-expect-error
assertType<Nation | Nation[]>(nation)

expect(nation.name).toBe('Madagascar')
//@ts-ignore
expect(nation.name).toBe('Great_Bulgaria')
})
})
2 changes: 1 addition & 1 deletion tests/squaremap/towns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('[Squaremap/Aurora] Towns', () => {

// TODO: Verify there are no duplicates residents.
it('can get single town', async () => {
const town = await Aurora.Towns.get('venice')
const town = await Aurora.Towns.get('fanagoria')
expect(town).toBeTruthy()
expect(town).toBeDefined()

Expand Down

0 comments on commit a244b56

Please sign in to comment.