-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
417 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import { setupServer } from "msw/node"; | ||
|
||
import { buildNodeConfiguration } from "../utils/public"; | ||
import { getAlias } from "./getAlias"; | ||
|
||
const server = setupServer(); | ||
|
||
describe("Function: getAlias", () => { | ||
// MSW Setup | ||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
it("returns alias for address", async () => { | ||
// ARRANGE | ||
const nodeConfiguration = buildNodeConfiguration({ | ||
url: "http://localhost", | ||
}); | ||
|
||
const mockResponse = { | ||
status: "ok", | ||
data: "PXGAMER", | ||
coin: "arionum", | ||
}; | ||
|
||
let requestUrl = ""; | ||
|
||
server.use( | ||
http.get(`http://localhost/api.php`, (info) => { | ||
requestUrl = info.request.url; | ||
return HttpResponse.json(mockResponse); | ||
}), | ||
); | ||
|
||
// ACT | ||
const response = await getAlias(nodeConfiguration, { | ||
address: | ||
"51sJ4LbdKzhyGy4zJGqodNLse9n9JsVT2rdeH92w7cf3qQuSDJupvjbUT1UBr7r1SCUAXG97saxn7jt2edKb4v4J", | ||
}); | ||
|
||
// ASSERT | ||
expect(requestUrl).toContain( | ||
"account=51sJ4LbdKzhyGy4zJGqodNLse9n9JsVT2rdeH92w7cf3qQuSDJupvjbUT1UBr7r1SCUAXG97saxn7jt2edKb4v4J", | ||
); | ||
|
||
expect(response).toEqual("PXGAMER"); | ||
}); | ||
|
||
it("returns alias with public key validation", async () => { | ||
// ARRANGE | ||
const nodeConfiguration = buildNodeConfiguration({ | ||
url: "http://localhost", | ||
}); | ||
|
||
const mockResponse = { | ||
status: "ok", | ||
data: "PXGAMER", | ||
coin: "arionum", | ||
}; | ||
|
||
let requestUrl = ""; | ||
|
||
server.use( | ||
http.get(`http://localhost/api.php`, (info) => { | ||
requestUrl = info.request.url; | ||
return HttpResponse.json(mockResponse); | ||
}), | ||
); | ||
|
||
// ACT | ||
const response = await getAlias(nodeConfiguration, { | ||
publicKey: | ||
"PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCyk7aKeBJ6LL44w5JGSFp82Wb1Drqicuznv1qmRVQMvbmF64AeczjMtV72acGLR9RsiQ2JccemNrSPkKi8KDk72t4", | ||
}); | ||
|
||
// ASSERT | ||
expect(requestUrl).toContain( | ||
"public_key=PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCyk7aKeBJ6LL44w5JGSFp82Wb1Drqicuznv1qmRVQMvbmF64AeczjMtV72acGLR9RsiQ2JccemNrSPkKi8KDk72t4", | ||
); | ||
|
||
expect(response).toEqual("PXGAMER"); | ||
}); | ||
}); |
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,166 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import { setupServer } from "msw/node"; | ||
|
||
import { buildNodeConfiguration } from "../utils/public"; | ||
import { getAssetBalance } from "./getAssetBalance"; | ||
|
||
const server = setupServer(); | ||
|
||
describe("Function: getAssetBalance", () => { | ||
// MSW Setup | ||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
it("returns asset balances for asset", async () => { | ||
// ARRANGE | ||
const nodeConfiguration = buildNodeConfiguration({ | ||
url: "http://localhost", | ||
}); | ||
|
||
const mockResponse = { | ||
status: "ok", | ||
data: [ | ||
{ | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
alias: "AUOS", | ||
account: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
balance: 1234, | ||
}, | ||
], | ||
coin: "arionum", | ||
}; | ||
|
||
let requestUrl = ""; | ||
|
||
server.use( | ||
http.get(`http://localhost/api.php`, (info) => { | ||
requestUrl = info.request.url; | ||
return HttpResponse.json(mockResponse); | ||
}), | ||
); | ||
|
||
// ACT | ||
const response = await getAssetBalance(nodeConfiguration, { | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
}); | ||
|
||
// ASSERT | ||
expect(requestUrl).toContain( | ||
"asset=63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
); | ||
|
||
expect(response).toEqual([ | ||
{ | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
alias: "AUOS", | ||
address: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
balance: 1234, | ||
}, | ||
]); | ||
}); | ||
|
||
it("returns asset balances for account", async () => { | ||
// ARRANGE | ||
const nodeConfiguration = buildNodeConfiguration({ | ||
url: "http://localhost", | ||
}); | ||
|
||
const mockResponse = { | ||
status: "ok", | ||
data: [ | ||
{ | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
alias: "AUOS", | ||
account: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
balance: 1234, | ||
}, | ||
], | ||
coin: "arionum", | ||
}; | ||
|
||
let requestUrl = ""; | ||
|
||
server.use( | ||
http.get(`http://localhost/api.php`, (info) => { | ||
requestUrl = info.request.url; | ||
return HttpResponse.json(mockResponse); | ||
}), | ||
); | ||
|
||
// ACT | ||
const response = await getAssetBalance(nodeConfiguration, { | ||
address: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
}); | ||
|
||
// ASSERT | ||
expect(requestUrl).toContain( | ||
"account=2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
); | ||
|
||
expect(response).toEqual([ | ||
{ | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
alias: "AUOS", | ||
address: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
balance: 1234, | ||
}, | ||
]); | ||
}); | ||
|
||
it("returns asset balances for public key", async () => { | ||
// ARRANGE | ||
const nodeConfiguration = buildNodeConfiguration({ | ||
url: "http://localhost", | ||
}); | ||
|
||
const mockResponse = { | ||
status: "ok", | ||
data: [ | ||
{ | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
alias: "AUOS", | ||
account: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
balance: 1234, | ||
}, | ||
], | ||
coin: "arionum", | ||
}; | ||
|
||
let requestUrl = ""; | ||
|
||
server.use( | ||
http.get(`http://localhost/api.php`, (info) => { | ||
requestUrl = info.request.url; | ||
return HttpResponse.json(mockResponse); | ||
}), | ||
); | ||
|
||
// ACT | ||
const response = await getAssetBalance(nodeConfiguration, { | ||
publicKey: | ||
"PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCzZitehhR4qa7Xe2Fz3ZHHb3njMbyKFohQqdPeYvDKdtHzCCgC9Nqs4DwF294Qqqms5HMjMRCkqmpE7qc8nEarC6m", | ||
}); | ||
|
||
// ASSERT | ||
expect(requestUrl).toContain( | ||
"public_key=PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCzZitehhR4qa7Xe2Fz3ZHHb3njMbyKFohQqdPeYvDKdtHzCCgC9Nqs4DwF294Qqqms5HMjMRCkqmpE7qc8nEarC6m", | ||
); | ||
|
||
expect(response).toEqual([ | ||
{ | ||
asset: "63XhfCKHGCDUhwzWgb61nhNY7SD5HTTAV1XZ9fVqPAAe9oGyRtQruojT13A3pmWFEugd99qMDgGbgbQzPCE5ciHE", | ||
alias: "AUOS", | ||
address: | ||
"2MhGjby9kNXNgjViGNqACEASiZMxqT7JQGgiAbYnqG5mZ44AeUbtjRWDusAPKxFLng5ioi6dxyhFzQ33RzoH9SX5", | ||
balance: 1234, | ||
}, | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.