Expand types & tests (#166)

* RegEx for alias

* Expand tests

* Cleanup naming

* Options & Struct tests

* Cleanup Length with tests

* Enum tests

* TODO... expand/question assumption

* Remove extra line

* Hashin tests (commented, encoding change)

* Export Type on Vector & Struct

* Test Type & Base

* Address FIXME & additional test

* Cleanup TODOs

* Add MisbehaviorReport

* Add index.ts combinators

* typo in export

* Comment typo

* Update index.ts

* Update MisbehaviorReport.ts

* Update MisbehaviorReport.spec.js

* Extract Bft, add SignedBlock (allow anonymous structures)

* <foo>Struct -> <foo>Value (for constructor args)

* AnyNumber/U8a types for inputs (PR comment)

* Comment struct generics

* Typo in comment

* Simplify StorageFunctionType construction

* Fix liniting (wtf?)

* Fix linting & tests, make more robust
This commit is contained in:
Jaco Greeff
2018-09-26 14:33:12 +02:00
committed by GitHub
parent 7eb2b29201
commit dfd2e70931
51 changed files with 988 additions and 147 deletions
@@ -0,0 +1,34 @@
// Copyright 2017-2018 @polkadot/api-codec authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Struct from './Struct';
import Text from '../Text';
import U32 from '../U32';
describe('Struct', () => {
it('provides a clean toString()', () => {
expect(
new (
Struct.with({
txt: Text,
u32: U32
})
)({ txt: 'foo', u32: 0x123456 }).toString()
).toEqual(`{txt: foo, u32: 0x00123456}`);
});
it('exposes the types', () => {
expect(
new Struct({
foo: Text,
bar: Text,
baz: U32
}).Type
).toEqual({
foo: 'Text',
bar: 'Text',
baz: 'U32'
});
});
});