mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* first part of transition * second part of transition * remove jest * bump up node version and playwright version * update all screenshots because of the new playwright version * fix tests * one more screenshot update
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { it, expect } from 'vitest';
|
|
|
|
import { extractVariables, getStringChunks, checkSummary } from './utils';
|
|
|
|
const template = '{action_type} {source_amount} {native} into {destination_amount} {destination_token}';
|
|
|
|
it('extracts variables names', () => {
|
|
const result = extractVariables(template);
|
|
expect(result).toEqual([ 'action_type', 'source_amount', 'native', 'destination_amount', 'destination_token' ]);
|
|
});
|
|
|
|
it('split string without capturing variables', () => {
|
|
const result = getStringChunks(template);
|
|
expect(result).toEqual([ '', ' ', ' ', ' into ', ' ', '' ]);
|
|
});
|
|
|
|
it('checks that summary is valid', () => {
|
|
const result = checkSummary('{foo} {native} {bar} {wei}', { foo: { type: 'string', value: 'foo' }, bar: { type: 'string', value: 'bar' } });
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it('checks that summary is invalid', () => {
|
|
|
|
// @ts-ignore:
|
|
const result = checkSummary('{foo} {native} {bar}', { foo: { type: 'string', value: null }, bar: { type: 'string', value: 'bar' } });
|
|
expect(result).toBe(false);
|
|
});
|