Files
tom goriunovandGitHub 5d337fc555 Migrate from Jest to Vitest (#3173)
* 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
2025-12-10 19:21:07 +01:00

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);
});