|
1 | 1 | // SPDX-FileCopyrightText: 2024 IEXEC BLOCKCHAIN TECH <[email protected]> |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -import { |
5 | | - assert, |
6 | | - describe, |
7 | | - newTypedMockEventWithParams, |
8 | | - test, |
9 | | -} from "matchstick-as/assembly/index"; |
10 | | -import { handleCreateCategory } from "../../src/Modules/IexecCategoryManager"; |
11 | | -import { ethereum } from "@graphprotocol/graph-ts"; |
12 | | -import { CreateCategory } from "../../generated/Core/IexecInterfaceToken"; |
| 4 | +import { ethereum } from '@graphprotocol/graph-ts'; |
| 5 | +import { assert, describe, newTypedMockEventWithParams, test } from 'matchstick-as/assembly/index'; |
| 6 | +import { CreateCategory } from '../../generated/Core/IexecInterfaceToken'; |
| 7 | +import { handleCreateCategory } from '../../src/Modules/IexecCategoryManager'; |
13 | 8 |
|
14 | | -describe("IexecCategoryManager", () => { |
15 | | - test("Should handle CreateCategory", () => { |
16 | | - const id = 0; |
17 | | - const name = "some-name"; |
18 | | - const description = "some-description"; |
19 | | - const workClockTimeRef = 1; |
20 | | - let mockEvent = newTypedMockEventWithParams<CreateCategory>([ |
21 | | - new ethereum.EventParam("id", ethereum.Value.fromI32(id)), |
22 | | - new ethereum.EventParam("name", ethereum.Value.fromString(name)), |
23 | | - new ethereum.EventParam( |
24 | | - "description", |
25 | | - ethereum.Value.fromString(description) |
26 | | - ), |
27 | | - new ethereum.EventParam( |
28 | | - "workClockTimeRef", |
29 | | - ethereum.Value.fromI32(workClockTimeRef) |
30 | | - ), |
31 | | - ]); |
| 9 | +describe('IexecCategoryManager', () => { |
| 10 | + test('Should handle CreateCategory', () => { |
| 11 | + const id = 0; |
| 12 | + const name = 'some-name'; |
| 13 | + const description = 'some-description'; |
| 14 | + const workClockTimeRef = 1; |
| 15 | + let mockEvent = newTypedMockEventWithParams<CreateCategory>([ |
| 16 | + new ethereum.EventParam('id', ethereum.Value.fromI32(id)), |
| 17 | + new ethereum.EventParam('name', ethereum.Value.fromString(name)), |
| 18 | + new ethereum.EventParam('description', ethereum.Value.fromString(description)), |
| 19 | + new ethereum.EventParam('workClockTimeRef', ethereum.Value.fromI32(workClockTimeRef)), |
| 20 | + ]); |
32 | 21 |
|
33 | | - handleCreateCategory(mockEvent); |
34 | | - assert.fieldEquals("Protocol", "iExec", "categoriesCount", "1"); |
35 | | - [ |
36 | | - ["name", name], |
37 | | - ["description", description], |
38 | | - ["workClockTimeRef", workClockTimeRef.toString()], |
39 | | - ["timestamp", "1"], |
40 | | - ].forEach((fieldNameAndExpectedValue) => { |
41 | | - const fieldName = fieldNameAndExpectedValue[0]; |
42 | | - const expectedValue = fieldNameAndExpectedValue[1]; |
43 | | - assert.fieldEquals("Category", id.toString(), fieldName, expectedValue); |
| 22 | + handleCreateCategory(mockEvent); |
| 23 | + assert.fieldEquals('Protocol', 'iExec', 'categoriesCount', '1'); |
| 24 | + [ |
| 25 | + ['name', name], |
| 26 | + ['description', description], |
| 27 | + ['workClockTimeRef', workClockTimeRef.toString()], |
| 28 | + ['timestamp', '1'], |
| 29 | + ].forEach((fieldNameAndExpectedValue) => { |
| 30 | + const fieldName = fieldNameAndExpectedValue[0]; |
| 31 | + const expectedValue = fieldNameAndExpectedValue[1]; |
| 32 | + assert.fieldEquals('Category', id.toString(), fieldName, expectedValue); |
| 33 | + }); |
44 | 34 | }); |
45 | | - }); |
46 | 35 | }); |
0 commit comments