mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 13:05:49 +00:00
98 lines
2.7 KiB
TypeScript
98 lines
2.7 KiB
TypeScript
import { assert } from 'chai'
|
|
|
|
import { validate, ValidationError } from '../../src'
|
|
import { validateTicketCreate } from '../../src/models/transactions/ticketCreate'
|
|
|
|
/**
|
|
* TicketCreate Transaction Verification Testing.
|
|
*
|
|
* Providing runtime verification testing for each specific transaction type.
|
|
*/
|
|
describe('TicketCreate', function () {
|
|
let ticketCreate
|
|
|
|
beforeEach(function () {
|
|
ticketCreate = {
|
|
TransactionType: 'TicketCreate',
|
|
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
|
|
NetworkID: 21338,
|
|
TicketCount: 150,
|
|
} as any
|
|
})
|
|
|
|
it('verifies valid TicketCreate', function () {
|
|
assert.doesNotThrow(() => validateTicketCreate(ticketCreate))
|
|
assert.doesNotThrow(() => validate(ticketCreate))
|
|
})
|
|
|
|
it('throws when TicketCount is missing', function () {
|
|
delete ticketCreate.TicketCount
|
|
assert.throws(
|
|
() => validateTicketCreate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: missing field TicketCount',
|
|
)
|
|
assert.throws(
|
|
() => validate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: missing field TicketCount',
|
|
)
|
|
})
|
|
|
|
it('throws when TicketCount is not a number', function () {
|
|
ticketCreate.TicketCount = '150'
|
|
assert.throws(
|
|
() => validateTicketCreate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be a number',
|
|
)
|
|
assert.throws(
|
|
() => validate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be a number',
|
|
)
|
|
})
|
|
|
|
it('throws when TicketCount is not an integer', function () {
|
|
ticketCreate.TicketCount = 12.5
|
|
assert.throws(
|
|
() => validateTicketCreate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be an integer from 1 to 250',
|
|
)
|
|
assert.throws(
|
|
() => validate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be an integer from 1 to 250',
|
|
)
|
|
})
|
|
|
|
it('throws when TicketCount is < 1', function () {
|
|
ticketCreate.TicketCount = 0
|
|
assert.throws(
|
|
() => validateTicketCreate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be an integer from 1 to 250',
|
|
)
|
|
assert.throws(
|
|
() => validate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be an integer from 1 to 250',
|
|
)
|
|
})
|
|
|
|
it('throws when TicketCount is > 250', function () {
|
|
ticketCreate.TicketCount = 251
|
|
assert.throws(
|
|
() => validateTicketCreate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be an integer from 1 to 250',
|
|
)
|
|
assert.throws(
|
|
() => validate(ticketCreate),
|
|
ValidationError,
|
|
'TicketCreate: TicketCount must be an integer from 1 to 250',
|
|
)
|
|
})
|
|
})
|