Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed Dec 4, 2024
1 parent 7bc6331 commit df97bd4
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/platform/events/asset-bundle-converted.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import expect from 'expect'
import { AssetBundleConvertedEvent, Events } from '../../../src'

describe('AssetBundleConverted Events tests', () => {
it('AssetBundleConvertedEvent static tests must pass', () => {
const event: AssetBundleConvertedEvent = {
type: Events.Type.ASSET_BUNDLE,
subType: Events.SubType.AssetBundle.CONVERTED,
key: 'key',
timestamp: 1,
metadata: {
entityId: 'baf',
platform: 'mac'
}
}

expect(AssetBundleConvertedEvent.validate(event)).toEqual(true)
expect(AssetBundleConvertedEvent.validate(null)).toEqual(false)
expect(AssetBundleConvertedEvent.validate({})).toEqual(false)
})
})
43 changes: 43 additions & 0 deletions test/platform/events/badges.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import expect from 'expect'
import { BadgeGrantedEvent, Events } from '../../../src'

describe('Badge Events tests', () => {
it('BadgeGrantedEvent static tests must pass', () => {
const event: BadgeGrantedEvent = {
type: Events.Type.BADGE,
subType: Events.SubType.Badge.GRANTED,
key: 'key',
timestamp: 1,
metadata: {
address: '0x',
badgeId: 'a-badge-id',
badgeImageUrl: 'https://an-url.tld',
badgeName: 'Badge Name'
}
}

expect(BadgeGrantedEvent.validate(event)).toEqual(true)
expect(BadgeGrantedEvent.validate(null)).toEqual(false)
expect(BadgeGrantedEvent.validate({})).toEqual(false)
})

it('BadgeGrantedEvent with tier badge id static tests must pass', () => {
const event: BadgeGrantedEvent = {
type: Events.Type.BADGE,
subType: Events.SubType.Badge.GRANTED,
key: 'key',
timestamp: 1,
metadata: {
address: '0x',
badgeId: 'a-badge-id',
badgeImageUrl: 'https://an-url.tld',
badgeName: 'Badge Name',
badgeTierName: 'tier-name'
}
}

expect(BadgeGrantedEvent.validate(event)).toEqual(true)
expect(BadgeGrantedEvent.validate(null)).toEqual(false)
expect(BadgeGrantedEvent.validate({})).toEqual(false)
})
})

0 comments on commit df97bd4

Please sign in to comment.