mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-22 21:25:49 +00:00
build: Initial linting setup (#1560)
* sets up linting config and runs `yarn lint --fix` once, so that all changes will show up correctly in future PRs. * Note that there are still a lot of linter errors.
This commit is contained in:
committed by
Mayukha Vadari
parent
12cfed5c17
commit
8b95ee5fab
@@ -1,83 +1,85 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyDepositPreauth } from './../../src/models/transactions/depositPreauth'
|
||||
import { assert } from 'chai'
|
||||
import { assert } from "chai";
|
||||
|
||||
import { ValidationError } from "xrpl-local/common/errors";
|
||||
|
||||
import { verifyDepositPreauth } from "../../src/models/transactions/depositPreauth";
|
||||
|
||||
/**
|
||||
* DepositPreauth Transaction Verification Testing
|
||||
* DepositPreauth Transaction Verification Testing.
|
||||
*
|
||||
* Providing runtime verification testing for each specific transaction type
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('DepositPreauth Transaction Verification', () => {
|
||||
let depositPreauth
|
||||
describe("DepositPreauth Transaction Verification", function () {
|
||||
let depositPreauth;
|
||||
|
||||
beforeEach(() => {
|
||||
depositPreauth = {
|
||||
TransactionType: 'DepositPreauth',
|
||||
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
|
||||
} as any
|
||||
})
|
||||
beforeEach(function () {
|
||||
depositPreauth = {
|
||||
TransactionType: "DepositPreauth",
|
||||
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
|
||||
} as any;
|
||||
});
|
||||
|
||||
it ('verifies valid DepositPreauth when only Authorize is provided', () => {
|
||||
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
|
||||
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth))
|
||||
})
|
||||
it("verifies valid DepositPreauth when only Authorize is provided", function () {
|
||||
depositPreauth.Authorize = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW";
|
||||
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth));
|
||||
});
|
||||
|
||||
it ('verifies valid DepositPreauth when only Unauthorize is provided', () => {
|
||||
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
|
||||
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth))
|
||||
})
|
||||
it("verifies valid DepositPreauth when only Unauthorize is provided", function () {
|
||||
depositPreauth.Unauthorize = "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n";
|
||||
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth));
|
||||
});
|
||||
|
||||
it ('throws when both Authorize and Unauthorize are provided', () => {
|
||||
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
|
||||
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: can't provide both Authorize and Unauthorize fields"
|
||||
)
|
||||
})
|
||||
it("throws when both Authorize and Unauthorize are provided", function () {
|
||||
depositPreauth.Authorize = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW";
|
||||
depositPreauth.Unauthorize = "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n";
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: can't provide both Authorize and Unauthorize fields"
|
||||
);
|
||||
});
|
||||
|
||||
it ('throws when neither Authorize nor Unauthorize are provided', () => {
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
'DepositPreauth: must provide either Authorize or Unauthorize field'
|
||||
)
|
||||
})
|
||||
it("throws when neither Authorize nor Unauthorize are provided", function () {
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: must provide either Authorize or Unauthorize field"
|
||||
);
|
||||
});
|
||||
|
||||
it ('throws when Authorize is not a string', () => {
|
||||
depositPreauth.Authorize = 1234
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
'DepositPreauth: Authorize must be a string'
|
||||
)
|
||||
})
|
||||
it("throws when Authorize is not a string", function () {
|
||||
depositPreauth.Authorize = 1234;
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: Authorize must be a string"
|
||||
);
|
||||
});
|
||||
|
||||
it ('throws when an Account attempts to preauthorize its own address', () => {
|
||||
depositPreauth.Authorize = depositPreauth.Account
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: Account can't preauthorize its own address"
|
||||
)
|
||||
})
|
||||
it("throws when an Account attempts to preauthorize its own address", function () {
|
||||
depositPreauth.Authorize = depositPreauth.Account;
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: Account can't preauthorize its own address"
|
||||
);
|
||||
});
|
||||
|
||||
it ('throws when Unauthorize is not a string', () => {
|
||||
depositPreauth.Unauthorize = 1234
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
'DepositPreauth: Unauthorize must be a string'
|
||||
)
|
||||
})
|
||||
it("throws when Unauthorize is not a string", function () {
|
||||
depositPreauth.Unauthorize = 1234;
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: Unauthorize must be a string"
|
||||
);
|
||||
});
|
||||
|
||||
it ('throws when an Account attempts to unauthorize its own address', () => {
|
||||
depositPreauth.Unauthorize = depositPreauth.Account
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: Account can't unauthorize its own address"
|
||||
)
|
||||
})
|
||||
})
|
||||
it("throws when an Account attempts to unauthorize its own address", function () {
|
||||
depositPreauth.Unauthorize = depositPreauth.Account;
|
||||
assert.throws(
|
||||
() => verifyDepositPreauth(depositPreauth),
|
||||
ValidationError,
|
||||
"DepositPreauth: Account can't unauthorize its own address"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user