-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xcm-api): Add support for new currency input types ✨
- Loading branch information
1 parent
3465e64
commit 5d8655a
Showing
23 changed files
with
440 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { Request } from '@nestjs/common'; | ||
|
||
export const mockRequestObject = () => { | ||
return { headers: {}, body: {}, query: {}, params: {} } as unknown as Request; | ||
}; | ||
export const mockRequestObject = { | ||
headers: {}, | ||
body: {}, | ||
query: {}, | ||
params: {}, | ||
} as unknown as Request; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
apps/xcm-api/src/transfer-info/transfer-info.controller.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
import { vi, describe, beforeEach, it, expect } from 'vitest'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { mockRequestObject } from '../testUtils.js'; | ||
import { AnalyticsService } from '../analytics/analytics.service.js'; | ||
import { TransferInfoController } from './transfer-info.controller.js'; | ||
import { TransferInfoService } from './transfer-info.service.js'; | ||
import { PatchedTransferInfoDto } from './dto/transfer-info.dto.js'; | ||
import { TTransferInfo } from '@paraspell/sdk'; | ||
|
||
describe('TransferInfoController', () => { | ||
let controller: TransferInfoController; | ||
let service: TransferInfoService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [TransferInfoController], | ||
providers: [ | ||
TransferInfoService, | ||
{ | ||
provide: AnalyticsService, | ||
useValue: { get: () => '', track: vi.fn() }, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
controller = module.get<TransferInfoController>(TransferInfoController); | ||
service = module.get<TransferInfoService>(TransferInfoService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
|
||
describe('generateXcmCall', () => { | ||
it('should call generateXcmCall service method with correct parameters and return result', async () => { | ||
const queryParams: PatchedTransferInfoDto = { | ||
origin: 'Acala', | ||
destination: 'Basilisk', | ||
accountOrigin: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96', | ||
accountDestination: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96', | ||
currency: { symbol: 'DOT' }, | ||
amount: 100, | ||
}; | ||
const mockResult = {} as TTransferInfo; | ||
vi.spyOn(service, 'getTransferInfo').mockResolvedValue(mockResult); | ||
|
||
const result = await controller.getTransferInfo( | ||
queryParams, | ||
mockRequestObject, | ||
); | ||
|
||
expect(result).toBe(mockResult); | ||
expect(service.getTransferInfo).toHaveBeenCalledWith(queryParams); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.