mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-02 10:05:49 +00:00
chore: rename test files (#2181)
This commit is contained in:
95
packages/xrpl/test/models/ticketCreate.test.ts
Normal file
95
packages/xrpl/test/models/ticketCreate.test.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { assert } from 'chai'
|
||||
import { validate, ValidationError } from 'xrpl-local'
|
||||
import { validateTicketCreate } from 'xrpl-local/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',
|
||||
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',
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user