mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-10 07:45: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(...)
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
const _ = require('lodash')
|
|
const { loadFixture } = require('./utils')
|
|
const { coreTypes } = require('../dist/types')
|
|
const { Amount } = coreTypes
|
|
const fixtures = loadFixture('data-driven-tests.json')
|
|
|
|
function amountErrorTests () {
|
|
_.filter(fixtures.values_tests, { type: 'Amount' }).forEach(f => {
|
|
// We only want these with errors
|
|
if (!f.error) {
|
|
return
|
|
}
|
|
const testName = `${JSON.stringify(f.test_json)}\n\tis invalid ` +
|
|
`because: ${f.error}`
|
|
it(testName, () => {
|
|
expect(() => {
|
|
Amount.from(f.test_json)
|
|
JSON.stringify(f.test_json)
|
|
}).toThrow()
|
|
})
|
|
})
|
|
}
|
|
|
|
describe('Amount', function () {
|
|
it('can be parsed from', function () {
|
|
expect(Amount.from('1000000') instanceof Amount).toBe(true)
|
|
expect(Amount.from('1000000').valueString()).toEqual('1000000')
|
|
const fixture = {
|
|
value: '1',
|
|
issuer: '0000000000000000000000000000000000000000',
|
|
currency: 'USD'
|
|
}
|
|
const amt = Amount.from(fixture)
|
|
const rewritten = {
|
|
value: '1',
|
|
issuer: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
|
currency: 'USD'
|
|
}
|
|
expect(amt.toJSON()).toEqual(rewritten)
|
|
})
|
|
amountErrorTests()
|
|
})
|