-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d665d5
commit 8608ba8
Showing
2 changed files
with
15 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
import { Contract } from './parser'; | ||
import { describe, expect, it } from "vitest" | ||
import { Contract } from "./parser"; | ||
import { describe, expect, it } from "vitest"; | ||
import { FieldElement } from "./felt"; | ||
import { EventAbi } from "starknet"; | ||
|
||
describe('Contract class tests', () => { | ||
const mockContractAddress: FieldElement = '0x0'; | ||
describe("Contract class tests", () => { | ||
const mockContractAddress: FieldElement = "0x0"; | ||
const mockEventAbi: EventAbi = { | ||
type: 'event', | ||
name: 'MockEvent', | ||
kind: 'struct', | ||
members: [{ name: 'param1', type: 'felt', kind: 'key' }], | ||
type: "event", | ||
name: "MockEvent", | ||
kind: "struct", | ||
members: [{ name: "param1", type: "felt", kind: "key" }], | ||
}; | ||
|
||
const mockContractAbi = [mockEventAbi]; | ||
|
||
it('should create an EventFilter for a valid event name', () => { | ||
it("should create an EventFilter for a valid event name", () => { | ||
const contract = new Contract(mockContractAddress, mockContractAbi); | ||
const filter = contract.eventFilter('MockEvent'); | ||
const filter = contract.eventFilter("MockEvent"); | ||
|
||
expect(filter).toBeDefined(); | ||
expect(filter.fromAddress).toBe(mockContractAddress); | ||
// Further assertions can be made based on the expected structure of EventFilter | ||
}); | ||
|
||
it('should throw an error for an invalid event name', () => { | ||
it("should throw an error for an invalid event name", () => { | ||
const contract = new Contract(mockContractAddress, mockContractAbi); | ||
|
||
expect(() => { | ||
contract.eventFilter('InvalidEvent'); | ||
}).toThrow('Event InvalidEvent not found in contract ABI'); | ||
contract.eventFilter("InvalidEvent"); | ||
}).toThrow("Event InvalidEvent not found in contract ABI"); | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters