Files
xahau.js/test/models/escrowCancel.ts
Nathan Nichols f95ffee0b0 refactor: define models for EscrowCancel (#1511)
refactor: define models for EscrowCancel (#1511)
2021-10-04 14:10:08 -04:00

65 lines
1.7 KiB
TypeScript

import { verifyEscrowCancel } from './../../src/models/transactions/escrowCancel'
import { assert } from 'chai'
import { ValidationError } from '../../src/common/errors'
/**
* Transaction Verification Testing
*
* Providing runtime verification testing for each specific transaction type
*/
describe('Transaction Verification', function () {
let cancel
beforeEach(() => {
cancel = {
TransactionType: "EscrowCancel",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
OfferSequence: 7,
}
})
it (`Valid EscrowCancel`, () => {
assert.doesNotThrow(() => verifyEscrowCancel(cancel))
})
it (`Invalid EscrowCancel missing owner`, () => {
delete cancel.Owner
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: missing Owner'
)
})
it (`Invalid EscrowCancel missing offerSequence`, () => {
delete cancel.OfferSequence
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: missing OfferSequence'
)
})
it (`Invalid OfferSequence`, () => {
cancel.Owner = 10
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: Owner must be a string'
)
})
it (`Invalid owner`, () => {
cancel.OfferSequence = "10"
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: OfferSequence must be a number'
)
})
})