mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 04:35:49 +00:00
* will compile as typescript * migrated test suite to use JestJS * Migrated to Jest testing framework and typescript source files * updated deps * updated prepublish * resolved 1 failing test * changed decimal .0 on four tests, it appears that these were the only four tests expecting integer values to have '.0' * added linter * added package-lock * removed tslint in favor of eslint * changed yarn to npm * updated version 2.6->3.0 * removing package lock * updated node version in nvmrc and jest version in package * removed nvmrc * removed some unused functions * replaced data driven with file from master * commitint yarn.lock * removing babel as a dependency in favor of typescript compiling to es5 * removing babel deps * resolved testing issues by migrating helper function * added partial linting functionality for test suite * updated imports for decodeLedgerData * updated test * updated yarn.lock * removed a console.log * added eslint-jest-plugin to package * reverting to old linting, will add linting in next PR * removed comments in shamap * re-adding .nvmrc * npm -> yarn * added . to .eslintrc * added .eslintrc * removing linting for this PR * Changed linting to print a message so that linting doesnt fail in CI * changing back * added newline so diff wont show * removed eslint deps, since linting will be dealt with in a later PR * changed function calls to describe(...)
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
const fixtures = require('./fixtures/codec-fixtures.json')
|
|
const { decode, encode, decodeLedgerData } = require('../dist')
|
|
|
|
function json (object) {
|
|
return JSON.stringify(object)
|
|
}
|
|
|
|
function truncateForDisplay (longStr) {
|
|
return longStr.slice(0, 10) + '...' + longStr.slice(-10)
|
|
}
|
|
|
|
describe('ripple-binary-codec', function () {
|
|
function makeSuite (name, entries) {
|
|
describe(name, function () {
|
|
entries.forEach((t, testN) => {
|
|
// eslint-disable-next-line max-len
|
|
test(`${name}[${testN}] can encode ${truncateForDisplay(json(t.json))} to ${truncateForDisplay(t.binary)}`,
|
|
() => {
|
|
expect(t.binary).toEqual(encode(t.json))
|
|
})
|
|
// eslint-disable-next-line max-len
|
|
test(`${name}[${testN}] can decode ${truncateForDisplay(t.binary)} to ${truncateForDisplay(json(t.json))}`,
|
|
() => {
|
|
const decoded = decode(t.binary)
|
|
expect(t.json).toEqual(decoded)
|
|
})
|
|
})
|
|
})
|
|
}
|
|
makeSuite('transactions', fixtures.transactions)
|
|
makeSuite('accountState', fixtures.accountState)
|
|
|
|
describe('ledgerData', function () {
|
|
if (fixtures.ledgerData) {
|
|
fixtures.ledgerData.forEach((t, testN) => {
|
|
test(`ledgerData[${testN}] can decode ${t.binary} to ${json(t.json)}`,
|
|
() => {
|
|
const decoded = decodeLedgerData(t.binary)
|
|
expect(t.json).toEqual(decoded)
|
|
})
|
|
})
|
|
}
|
|
})
|
|
})
|