Skip to content

Commit

Permalink
fix: adds missed mock (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
nostrdev-com committed Dec 16, 2024
1 parent 1d85499 commit ffce32d
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions backend/src/angor/tests/AngorTransactionDecoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import * as bitcoinJS from 'bitcoinjs-lib';
import AngorProjectRepository from '../../repositories/AngorProjectRepository';
import AngorInvestmentRepository from '../../repositories/AngorInvestmentRepository';
import DB from '../../database';

describe('AngorTransactionDecoder', () => {
describe('Decoding transaction for Angor project creation', () => {
Expand Down Expand Up @@ -141,9 +142,13 @@ describe('AngorTransactionDecoder', () => {

describe('decodeAndStoreProjectCreationTransaction', () => {
it('should call $setProject method of AngorProjectRepository', async () => {
const setProjectSpy = jest.spyOn(AngorProjectRepository, '$setProject');
const setProjectSpy = jest
.spyOn(AngorProjectRepository, '$setProject')
.mockImplementation(() => Promise.resolve());

setProjectSpy.mockImplementation(() => Promise.resolve());
const updateInvestmentStatusSpy = jest
.spyOn(AngorInvestmentRepository, '$updateInvestmentsStatus')
.mockImplementation(() => Promise.resolve());

const transactionStatus = AngorTransactionStatus.Confirmed;

Expand All @@ -170,6 +175,11 @@ describe('AngorTransactionDecoder', () => {
txid,
blockHeight
);

expect(updateInvestmentStatusSpy).toHaveBeenCalledWith(
addressOnFeeOutput,
transactionStatus
);
});
});

Expand Down Expand Up @@ -307,12 +317,12 @@ describe('AngorTransactionDecoder', () => {

describe('decodeAndStoreInvestmentTransaction', () => {
it('should call $getProject method of AngorProjectRepository', async () => {
const getProjectSpy = jest.spyOn(
const getProjectSpy = jest
.spyOn(
AngorProjectRepository,
'$getProjectByAddressOnFeeOutput'
);

getProjectSpy.mockImplementation(() => Promise.resolve(undefined));
)
.mockImplementation(() => Promise.resolve(undefined));

await angorDecoder.decodeAndStoreInvestmentTransaction(
transactionStatus
Expand All @@ -339,9 +349,8 @@ describe('AngorTransactionDecoder', () => {
const setInvestmentSpy = jest.spyOn(
AngorInvestmentRepository,
'$setInvestment'
);

setInvestmentSpy.mockImplementation(() => Promise.resolve());
)
.mockImplementation(() => Promise.resolve());

await angorDecoder.decodeAndStoreInvestmentTransaction(
transactionStatus
Expand Down

0 comments on commit ffce32d

Please sign in to comment.