Skip to content

Commit

Permalink
fix trim tests, add tag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenClontz committed Nov 25, 2023
1 parent ec3dee0 commit 3e15c37
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions packages/core/test/Id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,44 @@ describe('toInt', () => {

describe('trim', () => {
it('trims down to the numeric content', () => {
expect(trim('T000100')).toEqual(100)
expect(trim('T000100')).toEqual("100")
})

it('does not require leading zeros', () => {
expect(trim('P12')).toEqual(12)
expect(trim('P12')).toEqual("12")
})

it('does not match nonexistent kinds', () => {
expect(trim('Z000100')).toEqual(0)
it('returns self for nonexistent kinds', () => {
expect(trim('Z000100')).toEqual("Z000100")
})

it('matches unknown kind', () => {
expect(trim('000123')).toEqual(123)
expect(trim('000123')).toEqual("123")
})
})

describe('tag', () => {
it('tags spaces', () => {
expect(tag('S000100')?.kind).toEqual("space")
})

it('tags properties', () => {
expect(tag('P000100')?.kind).toEqual("property")
})

it('tags theorems', () => {
expect(tag('T000100')?.kind).toEqual("theorem")
})

it('tags unknowns', () => {
expect(tag('000100')?.kind).toEqual("unknown")
})

it('is null for nonexistent kinds', () => {
expect(tag('X000100')).toEqual(null)
})

it('allows lowercase', () => {
expect(tag('s000100')?.kind).toEqual("space")
})
})

0 comments on commit 3e15c37

Please sign in to comment.