// Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 import { typeSplit } from '.'; describe('typeSplit', (): void => { it('splits simple types into an array', (): void => { expect( typeSplit('Text, u32, u64') ).toEqual(['Text', 'u32', 'u64']); }); it('splits nested combinations', (): void => { expect( typeSplit('Text, (u32), Vec') ).toEqual(['Text', '(u32)', 'Vec']); }); it('keeps nested tuples together', (): void => { expect( typeSplit('Text, (u32, u128), Vec') ).toEqual(['Text', '(u32, u128)', 'Vec']); }); it('keeps nested vector tuples together', (): void => { expect( typeSplit('Text, (u32, u128), Vec<(u64, u32)>') ).toEqual(['Text', '(u32, u128)', 'Vec<(u64, u32)>']); }); it('allows for deep nesting', (): void => { expect( typeSplit('Text, (u32, (u128, u8)), Vec<(u64, (u32, u32))>') ).toEqual(['Text', '(u32, (u128, u8))', 'Vec<(u64, (u32, u32))>']); }); it('checks for unclosed vec', (): void => { expect( (): string[] => typeSplit('Text, Vec { expect( (): string[] => typeSplit('Text, (u64, u32') ).toThrow(/Invalid definition/); }); });