UNPKG

native-spa-route

Version:

provide SPA route's experience with native web component

28 lines (27 loc) 1.17 kB
import { html, fixture, expect } from '@open-wc/testing'; describe('route', () => { it('route match group parse [with vaild root path] [with regexp] [with group mode]', async () => { let el = await fixture(html ` <native-route path="/root"> <native-route path=":(?:hello)|(?:world)" groupMatchMode></native-route> </native-route> `); el = el.children[0]; const correct_ret = ['', 'root', /(?:hello)|(?:world)/]; expect(el._route_match_check_grouped_path).deep.equal(correct_ret); }); it('nest route test', async () => { // location.href = '/hello/world'; window.history.pushState({}, '', '/root/hello/world'); let el = await fixture(html ` <native-route path="/root"> <native-route path=":(?:hello)|(?:hello/world)" groupMatchMode></native-route> </native-route> `); console.log('location.href', location.href); el = el.children[0]; const correct_ret = ['', 'root', /(?:hello)|(?:hello\/world)/]; expect(el._route_match_check_grouped_path).deep.equal(correct_ret); expect(el.isActive()).equal(true); }); });