-
-
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.
[refactor] add Experimental Support of Nested Router
[add] User & Contributor document
- Loading branch information
Showing
13 changed files
with
336 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
test/ | ||
dist/ | ||
.rts2_cache_*/ | ||
.rts2_cache_*/ | ||
Contributing.md |
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,13 @@ | ||
# Contributor guide | ||
|
||
## Local development | ||
|
||
```shell | ||
git clone https://github.com/EasyWebApp/cell-router.git ~/Desktop/cell-router | ||
cd ~/Desktop/cell-router | ||
git checkout v2 | ||
|
||
npm install | ||
npm run set-chrome | ||
npm run debug | ||
``` |
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
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 |
---|---|---|
@@ -1,62 +1,52 @@ | ||
import { Page } from 'puppeteer-core'; | ||
import { bootServer, getPage } from './browser'; | ||
import { bootServer, getPage, expectPage } from './browser'; | ||
|
||
var server: string, page: Page; | ||
|
||
async function expectPage(content: string, title: string, path: string) { | ||
expect( | ||
await page.$eval('div', tag => [ | ||
tag.textContent, | ||
document.title, | ||
window.location.hash | ||
]) | ||
).toStrictEqual(expect.arrayContaining([content, title, path])); | ||
} | ||
|
||
describe('HTMLRouter', () => { | ||
describe('Simple router', () => { | ||
beforeAll(async () => { | ||
server = await bootServer(); | ||
|
||
page = await getPage(server); | ||
}); | ||
|
||
it('should render Router component', async () => { | ||
expect(await page.$eval('page-router', tag => tag.innerHTML)).toBe( | ||
expect(await page.$eval('simple-router', tag => tag.innerHTML)).toBe( | ||
'<main><ul><li><a href="test">Test</a></li><li><a href="example">Example</a></li></ul><div></div></main>' | ||
); | ||
}); | ||
|
||
it('should turn to a page after clicking a link', async () => { | ||
await page.click('li:first-child a'); | ||
await page.click('simple-router li:first-child a'); | ||
|
||
await expectPage('test', 'Test', '#test'); | ||
await expectPage('simple-router', 'test', 'Test', '#test'); | ||
|
||
await page.click('li:last-child a'); | ||
await page.click('simple-router li:last-child a'); | ||
|
||
await expectPage('example', 'Example', '#example'); | ||
await expectPage('simple-router', 'example', 'Example', '#example'); | ||
}); | ||
|
||
it('should turn to a page after navigating', async () => { | ||
await page.goBack(); | ||
|
||
await expectPage('test', 'Test', '#test'); | ||
await expectPage('simple-router', 'test', 'Test', '#test'); | ||
|
||
await page.goForward(); | ||
|
||
await expectPage('example', 'Example', '#example'); | ||
await expectPage('simple-router', 'example', 'Example', '#example'); | ||
}); | ||
|
||
it('should render a page based on Router path after reloading', async () => { | ||
await page.reload(); | ||
|
||
await expectPage('example', 'Example', '#example'); | ||
await expectPage('simple-router', 'example', 'Example', '#example'); | ||
|
||
await page.goBack(); | ||
|
||
await expectPage('test', 'Test', '#test'); | ||
await expectPage('simple-router', 'test', 'Test', '#test'); | ||
|
||
await page.goBack(); | ||
|
||
await expectPage('', 'Cell Router', ''); | ||
await expectPage('simple-router', '', 'Cell Router', ''); | ||
}); | ||
}); |
Oops, something went wrong.