Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thesan committed Apr 11, 2024
1 parent b080cc1 commit ad1b4d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 17 additions & 4 deletions packages/ui/src/mocks/resolvers/baseResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,27 @@ const getFilter = (where: Record<string, any>) => {
}
}

if (['gte', 'lte'].includes(type)) {
const resultToBoolean: (a: number) => boolean = type == 'gte' ? (a) => a >= 0 : (a) => a <= 0
if (['gte', 'gt', 'lte', 'lt'].includes(type)) {
const compare = (a: number, b: number): boolean => {
switch (type) {
case 'gte':
return a >= b
case 'gt':
return a > b
case 'lte':
return a <= b
case 'lt':
return a < b
default:
return false
}
}
if (['createdAt', 'statusSetAtTime'].includes(field)) {
filters.push((model: Record<string, any>) =>
resultToBoolean(new Date(model[field]).getTime() - new Date(checkValue).getTime())
compare(new Date(model[field]).getTime(), new Date(checkValue).getTime())
)
} else {
filters.push((model: Record<string, any>) => resultToBoolean(model[field] - checkValue))
filters.push((model: Record<string, any>) => compare(model[field], checkValue))
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/ui/test/council/pages/PastCouncil.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ describe('UI: Past Council page', () => {

describe('Stats', () => {
beforeEach(async () => {
seedProposal(testProposals[0], mockServer.server)
const proposal = testProposals[1]
seedProposal(proposal, mockServer.server)
seedEvent(
{
id: '0',
inBlock: 5,
createdAt: '2021-10-07T11:47:39.042Z',
network: 'OLYMPIA',
proposalId: testProposals[0].id,
proposalId: proposal.id,
},
'ProposalExecutedEvent',
'ProposalDecisionMadeEvent',
mockServer.server
)
seedEvent(
Expand Down

0 comments on commit ad1b4d4

Please sign in to comment.