-
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.
fix: Add URI generation method in HandlerAgent class
A new method, 'generateURIFromCreateMessage', was added to the HandlerAgent class for URI generation from CreateMessage. A corresponding test for this functionality was also written and added to 'HandlerAgentUtils.test.ts'.
- Loading branch information
1 parent
d883121
commit a345def
Showing
2 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { CreateSkeetMessage, HandlerAgent } from "../../src"; | ||
import { AtpSessionData, BskyAgent } from "@atproto/api"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
jest.mock("@atproto/api", () => jest.genMockFromModule("@atproto/api")); | ||
|
||
describe("HandlerAgent", () => { | ||
let handlerAgent: HandlerAgent; | ||
const testHandle: string = "testhandle"; | ||
const testPassword: string = "testpassword"; | ||
let mockedAgent: BskyAgent; | ||
beforeEach(() => { | ||
mockedAgent = { | ||
session: { | ||
did: "did:plc:2bnsooklzchcu5ao7xdjosrs", | ||
} as AtpSessionData, | ||
} as BskyAgent; | ||
handlerAgent = new HandlerAgent( | ||
"agentName", | ||
testHandle, | ||
testPassword, | ||
mockedAgent, | ||
); | ||
}); | ||
|
||
it("generateURIFromCreateMessage creates expected uri", () => { | ||
const message: CreateSkeetMessage = { | ||
cid: "", | ||
collection: "", | ||
opType: "c", | ||
record: { | ||
$type: "", | ||
createdAt: "", | ||
subject: "" | ||
}, | ||
seq: 0, | ||
did: 'did:example:12345', | ||
rkey: 'feed1' | ||
// other necessary fields... | ||
}; | ||
const result = handlerAgent.generateURIFromCreateMessage(message); | ||
|
||
expect(result).toEqual('at://did:example:12345/app.bsky.feed.post/feed1'); | ||
}); | ||
|
||
}); |