Skip to content

Commit

Permalink
adds replacement for network id
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed May 24, 2024
1 parent 5380ef8 commit 8aa0b58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const handleReplacements = (html: string, opts: DevOptions): string => {
replacement: true
? `<near-social-viewer
${renderAttribute("src", opts.index)}
${renderAttribute("rpc", `http://127.0.0.1:${opts.port}/api/proxy-rpc`)}></near-social-viewer>`
${renderAttribute("rpc", `http://127.0.0.1:${opts.port}/api/proxy-rpc`)}
${renderAttribute("network", opts.network)}
></near-social-viewer>`
: "<near-social-viewer></near-social-viewer>",
}
}));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bos-workspace",
"version": "1.0.0-alpha.20",
"version": "1.0.0-alpha.21",
"description": "",
"bin": {
"bos-workspace": "./bin/bw.js",
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/gateway.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DevOptions } from '@/lib/dev';
import { Logger, LogLevel } from "@/lib/logger";
import { handleReplacements } from '@/lib/gateway';
import { Logger, LogLevel } from "@/lib/logger";
import { Network } from '@/lib/types';

const unmockedLog = global.log;
Expand Down Expand Up @@ -41,7 +41,7 @@ describe("gateway", () => {
// Test replacement of the near-social-viewer component with an RPC attribute
it("should replace <near-social-viewer></near-social-viewer> with near-social-viewer having an RPC attribute", () => {
const htmlInput = "<html><head></head><body><near-social-viewer></near-social-viewer></body></html>";
const expectedHtmlOutput = `<html><head></head><body><near-social-viewer src="${mockOpts.index}" rpc="http://127.0.0.1:${mockOpts.port}/api/proxy-rpc"></near-social-viewer></body></html>`;
const expectedHtmlOutput = `<html><head></head><body><near-social-viewer src="${mockOpts.index}" rpc="http://127.0.0.1:${mockOpts.port}/api/proxy-rpc" network="${mockOpts.network}"></near-social-viewer></body></html>`;

const result = handleReplacements(htmlInput, mockOpts);
expect(result).toBe(expectedHtmlOutput);
Expand Down

0 comments on commit 8aa0b58

Please sign in to comment.