Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Nov 29, 2023
1 parent d22918d commit bfbb7f3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/utils/topic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { buildContentTopic, isValidTopic } from '../../src/utils/topic'

describe('topic utils', () => {
describe('isValidTopic', () => {
it('validates topics correctly', () => {
expect(isValidTopic(buildContentTopic('foo'))).toBe(true)
expect(isValidTopic(buildContentTopic('123'))).toBe(true)
expect(isValidTopic(buildContentTopic('bar987'))).toBe(true)
expect(isValidTopic(buildContentTopic('*&+-)'))).toBe(true)
expect(isValidTopic(buildContentTopic('%#@='))).toBe(true)
expect(isValidTopic(buildContentTopic('<;.">'))).toBe(true)
expect(isValidTopic(buildContentTopic(String.fromCharCode(33)))).toBe(
true
)
expect(isValidTopic(buildContentTopic('∫ß'))).toBe(false)
expect(isValidTopic(buildContentTopic('\xA9'))).toBe(false)
expect(isValidTopic(buildContentTopic('\u2665'))).toBe(false)
expect(isValidTopic(buildContentTopic(String.fromCharCode(1)))).toBe(
false
)
expect(isValidTopic(buildContentTopic(String.fromCharCode(23)))).toBe(
false
)
})
})
})

0 comments on commit bfbb7f3

Please sign in to comment.