You've already forked tf2wikipricing
test: add item schema tests
This commit is contained in:
27
__tests__/schema.test.ts
Normal file
27
__tests__/schema.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { ItemSchema, getItemIndexByName, getTradableStatusByDefindex, getTradableStatusByName} from '../src/content/schemaService'
|
||||
|
||||
const mockSchema: ItemSchema = {
|
||||
'5021': { name: 'Mann Co. Supply Crate Key', tradable: true },
|
||||
'15013': { name: 'Non-Tradable Item', tradable: false }
|
||||
}
|
||||
|
||||
describe('Schema Service', () => {
|
||||
|
||||
test('getItemIndexByName returns correct defindex', () => {
|
||||
expect(getItemIndexByName(mockSchema, 'Mann Co. Supply Crate Key')).toBe(5021)
|
||||
expect(getItemIndexByName(mockSchema, 'Non-Existent Item')).toBeNull()
|
||||
})
|
||||
|
||||
test('getTradableStatusByDefindex returns correct status', () => {
|
||||
expect(getTradableStatusByDefindex(mockSchema, 5021)).toBe(true)
|
||||
expect(getTradableStatusByDefindex(mockSchema, 15013)).toBe(false)
|
||||
expect(() => getTradableStatusByDefindex(mockSchema, 999)).toThrow()
|
||||
})
|
||||
|
||||
test('getTradableStatusByName returns correct status', () => {
|
||||
expect(getTradableStatusByName(mockSchema, 'Mann Co. Supply Crate Key')).toBe(true)
|
||||
expect(getTradableStatusByName(mockSchema, 'Non-Tradable Item')).toBe(false)
|
||||
expect(getTradableStatusByName(mockSchema, 'Non-Existent Item')).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user