Skip to content

Commit ea54370

Browse files
committed
refactor: better filename to avoid confusion
1 parent e7f0ecf commit ea54370

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed
File renamed without changes.

src/writer/proposal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { containsFlaggedLinks, flaggedAddresses } from '../helpers/moderation';
88
import { isMalicious } from '../helpers/monitoring';
99
import db from '../helpers/mysql';
1010
import { getLimits, getSpaceType } from '../helpers/options';
11+
import { validateSpaceSettings } from '../helpers/spaceValidation';
1112
import { captureError, getQuorum, jsonParse, validateChoices } from '../helpers/utils';
12-
import { validateSpaceSettings } from '../helpers/validation';
1313

1414
const scoreAPIUrl = process.env.SCORE_API_URL || 'https://score.snapshot.org';
1515
const broviderUrl = process.env.BROVIDER_URL || 'https://rpc.snapshot.org';

src/writer/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { addOrUpdateSpace, getSpace } from '../helpers/actions';
44
import log from '../helpers/log';
55
import db from '../helpers/mysql';
66
import { getLimit, getSpaceType } from '../helpers/options';
7+
import { validateSpaceSettings } from '../helpers/spaceValidation';
78
import {
89
addToWalletConnectWhitelist,
910
clearStampCache,
1011
getSpaceController,
1112
jsonParse,
1213
removeFromWalletConnectWhitelist
1314
} from '../helpers/utils';
14-
import { validateSpaceSettings } from '../helpers/validation';
1515

1616
const SNAPSHOT_ENV = process.env.NETWORK || 'testnet';
1717

test/unit/helpers/validation.test.ts renamed to test/unit/helpers/spaceValidation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jest.mock('../../../src/helpers/log', () => ({
1717
warn: jest.fn()
1818
}));
1919

20-
import { validateSpaceSettings } from '../../../src/helpers/validation';
20+
import { validateSpaceSettings } from '../../../src/helpers/spaceValidation';
2121

22-
describe('helpers/validation', () => {
22+
describe('helpers/spaceValidation', () => {
2323
describe('validateSpaceSettings()', () => {
2424
beforeEach(() => {
2525
jest.clearAllMocks();

test/unit/writer/proposal.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
// Mock validateSpaceSettings function
2+
jest.mock('../../../src/helpers/spaceValidation', () => ({
3+
validateSpaceSettings: jest.fn()
4+
}));
5+
16
import omit from 'lodash/omit';
7+
import * as writer from '../../../src/writer/proposal';
28
import { spacesGetSpaceFixtures } from '../../fixtures/space';
39
import input from '../../fixtures/writer-payload/proposal.json';
410

@@ -92,16 +98,10 @@ jest.mock('../../../src/helpers/moderation', () => {
9298
};
9399
});
94100

95-
// Mock validateSpaceSettings function
96-
jest.mock('../../../src/helpers/validation', () => ({
97-
validateSpaceSettings: jest.fn()
98-
}));
99-
100101
// Get the mocked function after the mock is created
101-
const { validateSpaceSettings: mockValidateSpaceSettings } = jest.requireMock('../../../src/helpers/validation');
102-
103-
// Import after mocks are set up
104-
import * as writer from '../../../src/writer/proposal';
102+
const { validateSpaceSettings: mockValidateSpaceSettings } = jest.requireMock(
103+
'../../../src/helpers/spaceValidation'
104+
);
105105

106106
const mockGetProposalsCount = jest.spyOn(writer, 'getProposalsCount');
107107
mockGetProposalsCount.mockResolvedValue([
@@ -123,7 +123,7 @@ describe('writer/proposal', () => {
123123
// Default validateSpaceSettings to resolve (success)
124124
mockValidateSpaceSettings.mockResolvedValue(undefined);
125125
});
126-
126+
127127
afterEach(jest.clearAllMocks);
128128

129129
const msg = JSON.parse(input.msg);
@@ -175,7 +175,6 @@ describe('writer/proposal', () => {
175175
expect(mockGetProposalsCount).toHaveBeenCalledTimes(1);
176176
});
177177

178-
179178
describe('when the space has set a voting period', () => {
180179
const VOTING_PERIOD = 120;
181180
const msg = JSON.parse(input.msg);

test/unit/writer/settings.test.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Mock validateSpaceSettings function
2+
jest.mock('../../../src/helpers/spaceValidation', () => ({
3+
validateSpaceSettings: jest.fn()
4+
}));
5+
6+
import { verify } from '../../../src/writer/settings';
17
import { spacesGetSpaceFixtures } from '../../fixtures/space';
28
import input from '../../fixtures/writer-payload/space.json';
39

@@ -101,16 +107,10 @@ jest.mock('@snapshot-labs/snapshot.js', () => {
101107
};
102108
});
103109

104-
// Mock validateSpaceSettings function
105-
jest.mock('../../../src/helpers/validation', () => ({
106-
validateSpaceSettings: jest.fn()
107-
}));
108-
109110
// Get the mocked function after the mock is created
110-
const { validateSpaceSettings: mockValidateSpaceSettings } = jest.requireMock('../../../src/helpers/validation');
111-
112-
// Import after mocks are set up
113-
import { verify } from '../../../src/writer/settings';
111+
const { validateSpaceSettings: mockValidateSpaceSettings } = jest.requireMock(
112+
'../../../src/helpers/spaceValidation'
113+
);
114114

115115
describe('writer/settings', () => {
116116
describe('verify()', () => {
@@ -234,12 +234,15 @@ describe('writer/settings', () => {
234234
it('calls validateSpaceSettings with correct parameters', async () => {
235235
await verify(input);
236236

237-
expect(mockValidateSpaceSettings).toHaveBeenCalledWith({
238-
...JSON.parse(input.msg).payload,
239-
id: JSON.parse(input.msg).space,
240-
deleted: spacesGetSpaceFixtures.deleted,
241-
turbo: spacesGetSpaceFixtures.turbo
242-
}, 'mainnet');
237+
expect(mockValidateSpaceSettings).toHaveBeenCalledWith(
238+
{
239+
...JSON.parse(input.msg).payload,
240+
id: JSON.parse(input.msg).space,
241+
deleted: spacesGetSpaceFixtures.deleted,
242+
turbo: spacesGetSpaceFixtures.turbo
243+
},
244+
'mainnet'
245+
);
243246
});
244247

245248
it('passes when validateSpaceSettings succeeds and strategy count is valid', async () => {

0 commit comments

Comments
 (0)