feat: solution for 'Повторный экзамен: Граф с рефлексией и доработкой'

This commit is contained in:
2026-07-01 16:14:52 +03:00
parent 1c6bbc04af
commit 5801947c0d
8 changed files with 376 additions and 279 deletions
+10
View File
@@ -0,0 +1,10 @@
const { Graph, createNode } = require('../src/index');
test('Graph runs nodes sequentially', () => {
const graph = new Graph();
graph.addNode(createNode('Rewrite', { pattern: /foo/g, replacement: 'bar' }));
graph.addNode(createNode('Reflection'));
const input = 'foo';
const output = graph.run(input);
expect(output).toBe('bar');
});
+8
View File
@@ -0,0 +1,8 @@
const { createNode } = require('../../src/index');
test('Reflection node returns input unchanged', () => {
const node = createNode('Reflection');
const input = { a: 1 };
const output = node.execute(input);
expect(output).toBe(input);
});
+8
View File
@@ -0,0 +1,8 @@
const { createNode } = require('../../src/index');
test('Rewrite node replaces pattern', () => {
const node = createNode('Rewrite', { pattern: /foo/g, replacement: 'bar' });
const input = 'foo baz foo';
const output = node.execute(input);
expect(output).toBe('bar baz bar');
});