| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- /**
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
- * SPDX-License-Identifier: MIT
- */
- import * as React from 'react';
- import { describe, test, expect, vi } from 'vitest';
- import { Container, interfaces } from 'inversify';
- import { render } from '@testing-library/react';
- import {
- FlowDocumentContainerModule,
- FlowTransitionLine,
- FlowTransitionLineEnum,
- } from '@flowgram.ai/document';
- import RoundedTurningLine from '../../src/components/RoundedTurningLine';
- function createDocumentContainer(): interfaces.Container {
- const container = new Container();
- container.load(FlowDocumentContainerModule);
- // container.bind(FlowDocumentContribution).to(FlowDocumentMockRegister);
- return container;
- }
- vi.mock('../../src/hooks/use-base-color.ts', () => ({
- useBaseColor: () => ({
- baseActivatedColor: '#fff',
- baseColor: '#fff',
- }),
- BASE_DEFAULT_COLOR: '#BBBFC4',
- BASE_DEFAULT_ACTIVATED_COLOR: '#82A7FC',
- }));
- describe('RoundedTurningLine', () => {
- test('should render RoundedTurningLine correctly', () => {
- const line: FlowTransitionLine = {
- type: FlowTransitionLineEnum.ROUNDED_LINE,
- from: {
- x: 0,
- y: 0,
- },
- to: {
- x: 100,
- y: 100,
- },
- vertices: [
- {
- x: 100,
- y: 0,
- },
- ],
- };
- const { container } = render(<RoundedTurningLine {...line} />);
- expect(container.querySelector('path')).toBeDefined();
- });
- test('should render RoundedTurningLine horizontal & arrow & active', () => {
- const line: FlowTransitionLine = {
- type: FlowTransitionLineEnum.ROUNDED_LINE,
- from: {
- x: 0,
- y: 0,
- },
- to: {
- x: 100,
- y: 100,
- },
- activated: true,
- };
- const { container } = render(<RoundedTurningLine arrow={true} isHorizantal={true} {...line} />);
- expect(container.querySelector('path')).toBeDefined();
- });
- test('should render with vertices', () => {
- const line: FlowTransitionLine = {
- type: FlowTransitionLineEnum.ROUNDED_LINE,
- from: {
- x: 0,
- y: 0,
- },
- to: {
- x: 100,
- y: 100,
- },
- vertices: [
- {
- x: 0,
- y: 30,
- },
- {
- x: 0,
- y: 30,
- radiusX: 30,
- radiusY: 30,
- },
- {
- x: 0,
- y: 30,
- moveX: 10,
- moveY: 10,
- },
- {
- x: 50,
- y: 50,
- },
- ],
- activated: true,
- };
- const { container } = render(<RoundedTurningLine arrow={true} isHorizantal={true} {...line} />);
- expect(container.querySelector('path')).toBeDefined();
- });
- test('should hide RoundedTurningLine', () => {
- const line: FlowTransitionLine = {
- type: FlowTransitionLineEnum.ROUNDED_LINE,
- from: {
- x: 0,
- y: 0,
- },
- to: {
- x: 100,
- y: 100,
- },
- };
- const { container } = render(<RoundedTurningLine hide={true} {...line} />);
- expect(container.querySelector('path')).toBeNull();
- });
- });
|