refactor: add verify() function (#1552)

* refactor: add verify() function
This commit is contained in:
Mukul Jangid
2021-09-13 11:31:29 -04:00
committed by Mayukha Vadari
parent 0d32071e0e
commit 148cac6f3f
21 changed files with 732 additions and 103 deletions

View File

@@ -1,8 +1,7 @@
import { assert } from 'chai'
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyTicketCreate } from '../../src/models/transactions/ticketCreate'
import { verifyTicketCreate } from './../../src/models/transactions/ticketCreate'
import { assert } from 'chai'
import { verify } from '../../src/models/transactions'
/**
* TicketCreate Transaction Verification Testing.
@@ -22,6 +21,7 @@ describe('TicketCreate', function () {
it('verifies valid TicketCreate', function () {
assert.doesNotThrow(() => verifyTicketCreate(ticketCreate))
assert.doesNotThrow(() => verify(ticketCreate))
})
it('throws when TicketCount is missing', function () {
@@ -31,6 +31,11 @@ describe('TicketCreate', function () {
ValidationError,
'TicketCreate: missing field TicketCount',
)
assert.throws(
() => verify(ticketCreate),
ValidationError,
'TicketCreate: missing field TicketCount',
)
})
it('throws when TicketCount is not a number', function () {
@@ -40,6 +45,11 @@ describe('TicketCreate', function () {
ValidationError,
'TicketCreate: TicketCount must be a number',
)
assert.throws(
() => verify(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be a number',
)
})
it('throws when TicketCount is not an integer', function () {
@@ -49,6 +59,11 @@ describe('TicketCreate', function () {
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
assert.throws(
() => verify(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
})
it('throws when TicketCount is < 1', function () {
@@ -58,6 +73,11 @@ describe('TicketCreate', function () {
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
assert.throws(
() => verify(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
})
it('throws when TicketCount is > 250', function () {
@@ -67,5 +87,10 @@ describe('TicketCreate', function () {
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
assert.throws(
() => verify(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250',
)
})
})