Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 76b178f

Browse files
author
Victor Wiebe
committed
feat: add title, description, isCostInPoly to wrappers with tests
1 parent 3a4de61 commit 76b178f

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

src/contract_wrappers/modules/__tests__/module_factory_wrapper.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,69 @@ describe('ModuleFactoryWrapper', () => {
6161
});
6262
});
6363

64+
describe('Title', () => {
65+
test('should get title', async () => {
66+
// Address expected
67+
const expectedResult = 'Title';
68+
// Mocked method
69+
const mockedMethod = mock(MockedCallMethod);
70+
// Stub the method
71+
when(mockedContract.title).thenReturn(instance(mockedMethod));
72+
// Stub the request
73+
when(mockedMethod.callAsync()).thenResolve(expectedResult);
74+
75+
// Real call
76+
const result = await target.title();
77+
// Result expectation
78+
expect(result).toBe(expectedResult);
79+
// Verifications
80+
verify(mockedContract.title).once();
81+
verify(mockedMethod.callAsync()).once();
82+
});
83+
});
84+
85+
describe('Description', () => {
86+
test('should get description', async () => {
87+
// Address expected
88+
const expectedResult = 'Description';
89+
// Mocked method
90+
const mockedMethod = mock(MockedCallMethod);
91+
// Stub the method
92+
when(mockedContract.description).thenReturn(instance(mockedMethod));
93+
// Stub the request
94+
when(mockedMethod.callAsync()).thenResolve(expectedResult);
95+
96+
// Real call
97+
const result = await target.description();
98+
// Result expectation
99+
expect(result).toBe(expectedResult);
100+
// Verifications
101+
verify(mockedContract.description).once();
102+
verify(mockedMethod.callAsync()).once();
103+
});
104+
});
105+
106+
describe('IsCostInPoly', () => {
107+
test('should get isCostInPoly', async () => {
108+
// Address expected
109+
const expectedResult = true;
110+
// Mocked method
111+
const mockedMethod = mock(MockedCallMethod);
112+
// Stub the method
113+
when(mockedContract.isCostInPoly).thenReturn(instance(mockedMethod));
114+
// Stub the request
115+
when(mockedMethod.callAsync()).thenResolve(expectedResult);
116+
117+
// Real call
118+
const result = await target.isCostInPoly();
119+
// Result expectation
120+
expect(result).toBe(expectedResult);
121+
// Verifications
122+
verify(mockedContract.isCostInPoly).once();
123+
verify(mockedMethod.callAsync()).once();
124+
});
125+
});
126+
64127
describe('Version', () => {
65128
test('should get version', async () => {
66129
// Address expected

src/contract_wrappers/modules/module_factory_wrapper.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,33 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
9292
return bytes32ToString(name);
9393
};
9494

95+
/**
96+
* Get the title of the Module
97+
*/
98+
public title = async (): Promise<string> => {
99+
return (await this.contract).title.callAsync();
100+
};
101+
102+
/**
103+
* Get isCostInPoly
104+
*/
105+
public isCostInPoly = async (): Promise<boolean> => {
106+
return (await this.contract).isCostInPoly.callAsync();
107+
};
108+
109+
/**
110+
* Get the description of the Module
111+
*/
112+
public description = async (): Promise<string> => {
113+
return (await this.contract).description.callAsync();
114+
};
115+
95116
/**
96117
* Get the version of the Module
97118
*/
98119
public version = async (): Promise<string> => {
99120
return (await this.contract).version.callAsync();
100-
}
121+
};
101122

102123
/**
103124
* Get setup cost

0 commit comments

Comments
 (0)