Skip to content

Commit

Permalink
URL-encode expanded word (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi authored Nov 1, 2024
1 parent f55de09 commit 18788d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,22 @@ jobs:
with:
access_token: ${{ github.token }}

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set node version to ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install -g [email protected] && yarn
- name: Run unit tests
run: yarn test

list-e2e-specs:
needs: unit-tests
name: Enumerate E2E tests and prepare to run them in parallel
runs-on: ubuntu-latest
outputs:
Expand Down
12 changes: 4 additions & 8 deletions src/App.test.tsx → src/components/Webservice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
import {urlEncode} from "./Webservice";

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
test("term, which is to be expanded, is URL encoded", () => {
expect(urlEncode("Ich gehe in den/in die/ins")).toEqual("Ich%20gehe%20in%20den%2Fin%20die%2Fins")
})
6 changes: 5 additions & 1 deletion src/components/Webservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function expand(term: string): Promise<Map<string, Array<any>>> {
graph.set("nodes", [])
graph.set("links", [])

await fetch(new URL("wilhelm/expand/" + term, WEBSERVICE_URL))
await fetch(new URL("wilhelm/expand/" + urlEncode(term), WEBSERVICE_URL))
.then(response => response.json())
.then(data => {
for (let node of data["nodes"]) {
Expand All @@ -86,3 +86,7 @@ export async function expand(term: string): Promise<Map<string, Array<any>>> {

return graph
}

export function urlEncode(term: string): string {
return encodeURIComponent(term)
}

0 comments on commit 18788d8

Please sign in to comment.