Skip to content

Commit f58d0fa

Browse files
committed
chore: add branch coverage
1 parent 5abbe44 commit f58d0fa

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ lib
99
launch
1010

1111
yarn-error.log
12+
coverage

jest.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ const nodeEnv = process.env.NODE_ENV || 'test';
22
process.env.NODE_ENV = nodeEnv;
33

44
if (nodeEnv !== 'test' && nodeEnv !== 'ci') {
5-
throw new Error(`Wrong environment for running tests, should be 'test' or 'ci'. NODE_ENV=${nodeEnv}`);
5+
throw new Error(
6+
`Wrong environment for running tests, should be 'test' or 'ci'. NODE_ENV=${nodeEnv}`,
7+
);
68
}
79

810
module.exports = {
@@ -14,5 +16,5 @@ module.exports = {
1416
testRegex: '.spec.ts$',
1517
testTimeout: 10000,
1618
transform: { '^.+\\.ts$': 'ts-jest' },
17-
coveragePathIgnorePatterns: [],
19+
coveragePathIgnorePatterns: ['contracts', 'generated'],
1820
};

src/vaults/__snapshots__/vaults.utils.spec.ts.snap

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`vaults.utils loadVaultPerformanceEvents loads no events if not available 1`] = `
4+
Object {
5+
"data": Array [],
6+
}
7+
`;
8+
39
exports[`vaults.utils loadVaultPerformanceEvents loads recent vault harvests and tree distributions 1`] = `
410
Object {
511
"data": Array [
@@ -59,6 +65,12 @@ Object {
5965
}
6066
`;
6167

68+
exports[`vaults.utils loadVaultV15PerformanceEvents loads no events if not available 1`] = `
69+
Object {
70+
"data": Array [],
71+
}
72+
`;
73+
6274
exports[`vaults.utils loadVaultV15PerformanceEvents loads recent vault harvests and tree distributions 1`] = `
6375
Object {
6476
"data": Array [

src/vaults/vaults.utils.spec.ts

+40
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe('vaults.utils', () => {
132132

133133
describe('timestampInRange', () => {
134134
const defaultTimestamp = Date.now();
135+
135136
it.each([
136137
[{}, defaultTimestamp, true],
137138
[{ timestamp_gte: defaultTimestamp }, defaultTimestamp, true],
@@ -171,6 +172,21 @@ describe('vaults.utils', () => {
171172
expect(timestampInRange(options, timestamp)).toEqual(expected);
172173
},
173174
);
175+
176+
it('throws an error on an invalid time range', () => {
177+
const upper = defaultTimestamp + 1;
178+
expect(() => {
179+
timestampInRange(
180+
{
181+
timestamp_gte: upper,
182+
timestamp_lte: defaultTimestamp,
183+
},
184+
defaultTimestamp,
185+
);
186+
}).toThrow(
187+
`Invalid time range check requested (${upper} - ${defaultTimestamp})`,
188+
);
189+
});
174190
});
175191

176192
describe('loadVaultPerformanceEvents', () => {
@@ -197,6 +213,18 @@ describe('vaults.utils', () => {
197213
const result = await loadVaultPerformanceEvents(testStrategy, {});
198214
expect(result).toMatchSnapshot();
199215
});
216+
217+
it('loads no events if not available', async () => {
218+
const testStrategy = Strategy__factory.connect(
219+
'0x1ccca1ce62c62f7be95d4a67722a8fdbed6eecb4',
220+
new ethers.providers.JsonRpcProvider(''),
221+
);
222+
jest
223+
.spyOn(testStrategy, 'queryFilter')
224+
.mockImplementation(async (_filter) => []);
225+
const result = await loadVaultPerformanceEvents(testStrategy, {});
226+
expect(result).toMatchSnapshot();
227+
});
200228
});
201229

202230
describe('loadVaultV15PerformanceEvents', () => {
@@ -223,5 +251,17 @@ describe('vaults.utils', () => {
223251
const result = await loadVaultV15PerformanceEvents(testVault, {});
224252
expect(result).toMatchSnapshot();
225253
});
254+
255+
it('loads no events if not available', async () => {
256+
const testVault = VaultV15__factory.connect(
257+
'0x1ccca1ce62c62f7be95d4a67722a8fdbed6eecb4',
258+
new ethers.providers.JsonRpcProvider(''),
259+
);
260+
jest
261+
.spyOn(testVault, 'queryFilter')
262+
.mockImplementation(async (_filter) => []);
263+
const result = await loadVaultV15PerformanceEvents(testVault, {});
264+
expect(result).toMatchSnapshot();
265+
});
226266
});
227267
});

0 commit comments

Comments
 (0)