github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/site/static/js/plugins/github_widget.test.js (about) 1 /** 2 * @jest-environment jsdom 3 */ 4 5 const plugins = require("./github_widget"); 6 7 test.each([ 8 [ 9 "https://github.com/GoogleContainerTools/kpt/issues/new?labels=documentation&title=Docs:%20title%20(https://test.test/book/01-the-chapter-title/)", 10 "https://github.com/GoogleContainerTools/kpt/edit/main/site/book/01-the-chapter-title/00.md", 11 "book/01-the-chapter-title/", 12 ], 13 [ 14 "https://github.com/GoogleContainerTools/kpt/issues/new?labels=documentation&title=Docs:%20title%20(https://test.test/book/01-the-chapter-title/05-page.md)", 15 "https://github.com/GoogleContainerTools/kpt/edit/main/site/book/01-the-chapter-title/05-page.md.md", 16 "book/01-the-chapter-title/05-page.md", 17 ], 18 [ 19 "https://github.com/GoogleContainerTools/kpt/issues/new?labels=documentation&title=Docs:%20title%20(https://test.test/faq/)", 20 "https://github.com/GoogleContainerTools/kpt/edit/main/site/faq/README.md", 21 "faq/", 22 ], 23 ])("github urls are correct", (expectedIssueUrl, expectedEditUrl, path) => { 24 // Configure test environment. 25 delete window.location; 26 window.location = new URL(path, "https://test.test"); 27 document.title = "title"; 28 const container = document.createElement("div"); 29 container.classList.add("docsify-pagination-container"); 30 31 document.body.append(container); 32 plugins.addGitHubWidget(); 33 const issueUrl = document.getElementById("create_issue_button").href; 34 const editUrl = document.getElementById("edit_page_button").href; 35 expect(issueUrl).toBe(expectedIssueUrl); 36 expect(editUrl).toBe(expectedEditUrl); 37 });