mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 12:10:24 +00:00
feat: Add Lint & Format (#878)
Co-authored-by: a7m-1st <Ahmed.jimi.awelkeir500@gmail.com> Co-authored-by: eigent-ai <camel@eigent.ai> Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com> Co-authored-by: Wendong-Fan <w3ndong.fan@gmail.com>
This commit is contained in:
parent
f256272eed
commit
af93bb3065
348 changed files with 48370 additions and 36145 deletions
|
|
@ -13,55 +13,55 @@
|
|||
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
||||
|
||||
// Simple example test to verify testing setup
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
describe('Basic Testing Setup', () => {
|
||||
it('should be able to run basic tests', () => {
|
||||
expect(1 + 1).toBe(2)
|
||||
})
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
||||
it('should handle string operations', () => {
|
||||
const greeting = 'Hello, World!'
|
||||
expect(greeting).toContain('World')
|
||||
expect(greeting.length).toBe(13)
|
||||
})
|
||||
const greeting = 'Hello, World!';
|
||||
expect(greeting).toContain('World');
|
||||
expect(greeting.length).toBe(13);
|
||||
});
|
||||
|
||||
it('should handle array operations', () => {
|
||||
const numbers = [1, 2, 3, 4, 5]
|
||||
expect(numbers).toHaveLength(5)
|
||||
expect(numbers).toContain(3)
|
||||
expect(numbers.reduce((a, b) => a + b, 0)).toBe(15)
|
||||
})
|
||||
const numbers = [1, 2, 3, 4, 5];
|
||||
expect(numbers).toHaveLength(5);
|
||||
expect(numbers).toContain(3);
|
||||
expect(numbers.reduce((a, b) => a + b, 0)).toBe(15);
|
||||
});
|
||||
|
||||
it('should handle async operations', async () => {
|
||||
const asyncFunction = () => Promise.resolve('async result')
|
||||
const result = await asyncFunction()
|
||||
expect(result).toBe('async result')
|
||||
})
|
||||
const asyncFunction = () => Promise.resolve('async result');
|
||||
const result = await asyncFunction();
|
||||
expect(result).toBe('async result');
|
||||
});
|
||||
|
||||
it('should handle mock functions', () => {
|
||||
const mockFn = vi.fn()
|
||||
mockFn('test argument')
|
||||
|
||||
expect(mockFn).toHaveBeenCalledOnce()
|
||||
expect(mockFn).toHaveBeenCalledWith('test argument')
|
||||
})
|
||||
})
|
||||
const mockFn = vi.fn();
|
||||
mockFn('test argument');
|
||||
|
||||
expect(mockFn).toHaveBeenCalledOnce();
|
||||
expect(mockFn).toHaveBeenCalledWith('test argument');
|
||||
});
|
||||
});
|
||||
|
||||
// Mock example
|
||||
|
||||
const mockMathOperations = {
|
||||
add: (a: number, b: number) => a + b,
|
||||
multiply: (a: number, b: number) => a * b
|
||||
}
|
||||
multiply: (a: number, b: number) => a * b,
|
||||
};
|
||||
|
||||
describe('Mock Example', () => {
|
||||
it('should mock functions correctly', () => {
|
||||
const mockAdd = vi.spyOn(mockMathOperations, 'add')
|
||||
mockAdd.mockReturnValue(10)
|
||||
|
||||
const result = mockMathOperations.add(2, 3)
|
||||
expect(result).toBe(10) // Returns mocked value, not actual sum
|
||||
expect(mockAdd).toHaveBeenCalledWith(2, 3)
|
||||
})
|
||||
})
|
||||
const mockAdd = vi.spyOn(mockMathOperations, 'add');
|
||||
mockAdd.mockReturnValue(10);
|
||||
|
||||
const result = mockMathOperations.add(2, 3);
|
||||
expect(result).toBe(10); // Returns mocked value, not actual sum
|
||||
expect(mockAdd).toHaveBeenCalledWith(2, 3);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue