fix: resolve TypeScript errors in test files
- Add type assertions for factory options arrays - Add 'this' type annotations to mock functions - Fix missing required properties in test objects - Change Mock to MockInstance for Vitest compatibility - Add non-null assertions where needed All 943 tests now passing
This commit is contained in:
@@ -13,30 +13,31 @@ export class MockDatabase {
|
||||
|
||||
prepare(sql: string) {
|
||||
const key = this.extractTableName(sql);
|
||||
const self = this;
|
||||
|
||||
return {
|
||||
all: vi.fn(() => this.data.get(key) || []),
|
||||
all: vi.fn(() => self.data.get(key) || []),
|
||||
get: vi.fn((id: string) => {
|
||||
const items = this.data.get(key) || [];
|
||||
const items = self.data.get(key) || [];
|
||||
return items.find(item => item.id === id);
|
||||
}),
|
||||
run: vi.fn((params: any) => {
|
||||
const items = this.data.get(key) || [];
|
||||
const items = self.data.get(key) || [];
|
||||
items.push(params);
|
||||
this.data.set(key, items);
|
||||
self.data.set(key, items);
|
||||
return { changes: 1, lastInsertRowid: items.length };
|
||||
}),
|
||||
iterate: vi.fn(function* () {
|
||||
const items = this.data.get(key) || [];
|
||||
const items = self.data.get(key) || [];
|
||||
for (const item of items) {
|
||||
yield item;
|
||||
}
|
||||
}),
|
||||
pluck: vi.fn(function() { return this; }),
|
||||
expand: vi.fn(function() { return this; }),
|
||||
raw: vi.fn(function() { return this; }),
|
||||
pluck: vi.fn(function(this: any) { return this; }),
|
||||
expand: vi.fn(function(this: any) { return this; }),
|
||||
raw: vi.fn(function(this: any) { return this; }),
|
||||
columns: vi.fn(() => []),
|
||||
bind: vi.fn(function() { return this; })
|
||||
bind: vi.fn(function(this: any) { return this; })
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -65,11 +65,11 @@ describe('Database Adapter - Unit Tests', () => {
|
||||
get: vi.fn(),
|
||||
all: vi.fn(() => []),
|
||||
iterate: vi.fn(function* () {}),
|
||||
pluck: vi.fn(function() { return this as any; }),
|
||||
expand: vi.fn(function() { return this as any; }),
|
||||
raw: vi.fn(function() { return this as any; }),
|
||||
pluck: vi.fn(function(this: any) { return this; }),
|
||||
expand: vi.fn(function(this: any) { return this; }),
|
||||
raw: vi.fn(function(this: any) { return this; }),
|
||||
columns: vi.fn(() => []),
|
||||
bind: vi.fn(function() { return this as any; })
|
||||
bind: vi.fn(function(this: any) { return this; })
|
||||
};
|
||||
|
||||
expect(mockStmt).toBeDefined();
|
||||
|
||||
@@ -136,13 +136,14 @@ describe('TemplateRepository - Core Functionality', () => {
|
||||
name: 'Test Workflow',
|
||||
description: 'A test workflow',
|
||||
user: {
|
||||
id: 1,
|
||||
name: 'John Doe',
|
||||
username: 'johndoe',
|
||||
verified: true
|
||||
},
|
||||
nodes: [
|
||||
{ name: 'n8n-nodes-base.httpRequest', position: [0, 0] },
|
||||
{ name: 'n8n-nodes-base.slack', position: [100, 0] }
|
||||
{ id: 1, name: 'n8n-nodes-base.httpRequest', icon: 'fa:globe' },
|
||||
{ id: 2, name: 'n8n-nodes-base.slack', icon: 'fa:slack' }
|
||||
],
|
||||
totalViews: 1000,
|
||||
createdAt: '2024-01-01T00:00:00Z'
|
||||
@@ -150,6 +151,10 @@ describe('TemplateRepository - Core Functionality', () => {
|
||||
|
||||
const detail: TemplateDetail = {
|
||||
id: 123,
|
||||
name: 'Test Workflow',
|
||||
description: 'A test workflow',
|
||||
views: 1000,
|
||||
createdAt: '2024-01-01T00:00:00Z',
|
||||
workflow: {
|
||||
nodes: [],
|
||||
connections: {},
|
||||
|
||||
Reference in New Issue
Block a user