-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bug-content-watcher-local-dev
- Loading branch information
Showing
5 changed files
with
71 additions
and
22 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
43 changes: 43 additions & 0 deletions
43
services/content-publishing/libs/common/src/utils/ipfs.client.spec.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,43 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { IpfsService } from './ipfs.client'; | ||
import { ConfigService } from '#libs/config'; | ||
import { Logger } from '@nestjs/common'; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('IpfsService Tests', () => { | ||
let service: IpfsService; | ||
let configService: ConfigService; | ||
let logger: Logger; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
IpfsService, | ||
{ | ||
provide: ConfigService, | ||
useValue: { | ||
ipfsEndpoint: 'http://localhost:5001', | ||
ipfsBasicAuthUser: '', | ||
ipfsBasicAuthSecret: '', | ||
ipfsGatewayUrl: 'http://localhost:8080/ipfs/[CID]', | ||
}, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<IpfsService>(IpfsService); | ||
configService = module.get<ConfigService>(ConfigService); | ||
logger = new Logger(IpfsService.name); | ||
}); | ||
|
||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it("hashes blake2b correctly ABC", async () => { | ||
const mb = await service.ipfsHashBuffer(Buffer.from("abc")); | ||
expect(mb).toMatch("bciqlu6awx6hqdt7kifaubxs5vyrchmadmgrzmf32ts2bb73b6iablli"); | ||
}); | ||
}); |
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