Skip to content

Commit

Permalink
Revert changes to test/cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ItalyPaleAle committed Dec 9, 2023
1 parent 15eee9c commit b8b7c05
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions test/cases/01-routing.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ describe('<Router> component', function() {
this.timeout(4000)

it('renders on the page', (browser) => {
browser.restart()

browser
.url(browser.launchUrl)
.expect.element('body').to.be.present.before(1000)

browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Home!')
.assert.containsText('h2.routetitle', 'Home!')

browser.end()
})

it('current path appears', (browser) => {
browser.restart()

browser
.url(browser.launchUrl)
.waitForElementVisible('#currentpath')
Expand All @@ -31,14 +29,12 @@ describe('<Router> component', function() {
})

it('selecting route from hash', (browser) => {
browser.restart()

// Main route
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Home!')
.assert.containsText('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
Expand All @@ -47,7 +43,7 @@ describe('<Router> component', function() {
browser
.url(browser.launchUrl + '/#/wild')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Wild')
.assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
Expand All @@ -56,95 +52,95 @@ describe('<Router> component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')

browser.end()
})

it('loading page with hash', (browser) => {
browser.restart()

browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')

browser.end()
})

it('refreshing page', (browser) => {
browser.restart()

// /hello/svelte
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')

browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')

browser.end()
})
})

it('catch-all route', (browser) => {
browser.restart()

browser
.url(browser.launchUrl + '/#/does/not/exist')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'NotFound')
.assert.containsText('h2.routetitle', 'NotFound')
.expect.element('#currentpath').text.to.equal('/does/not/exist')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"wild":"does/not/exist"}')

browser.end()
})

it('clicking on link', (browser) => {
browser.restart()

browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('ul.navigation-links')
.click('.navigation-links a[href="#/hello/svelte"]', () => {
browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')

browser
.expect.element('#nameparams').text.to.equal('Your name is: svelte')

browser.end()
})
})

it('clicking link with children', (browser) => {
browser.restart()

browser
.url(browser.launchUrl + '/#/hello/world')
.waitForElementVisible('ul.navigation-links')
.click('.navigation-links li a b', () => {
browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Home!')
.assert.containsText('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/brand')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')

browser.end()
})
})

it('back and forward buttons', (browser) => {
browser.restart()

browser
.url(browser.launchUrl + '/#/hello/svelte/user')
.waitForElementVisible('ul.navigation-links')
Expand All @@ -170,26 +166,28 @@ describe('<Router> component', function() {
browser
.waitForElementVisible('#nameparams')
.expect.element('#nameparams').text.to.equal('Your name is: svelte')

browser.end()
})
})
})
})

it('push method', (browser) => {
browser.restart()

browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('p.navigation-buttons')
.click('.navigation-buttons button:nth-of-type(1)', () => {
browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Wild')
.assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.expect.element('#currentparams').text.to.equal('{"wild":"something"}')

browser.url((url) => {
assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something')

browser.end()
})
})
})
Expand All @@ -206,7 +204,7 @@ describe('<Router> component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Wild')
.assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')

browser.url((url) => {
Expand All @@ -230,7 +228,7 @@ describe('<Router> component', function() {
.click('.navigation-buttons button:nth-of-type(3)', () => {
browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Wild')
.assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/replaced')

browser.url((url) => {
Expand All @@ -242,7 +240,7 @@ describe('<Router> component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Wild')
.assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')

browser.url((url) => {
Expand All @@ -262,15 +260,15 @@ describe('<Router> component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte?search=query&sort=0')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')

// Refresh the page
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Hi there!')
.assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')

Expand Down Expand Up @@ -320,7 +318,7 @@ describe('<Router> component', function() {
// Condition always fails
browser.url(browser.launchUrl + '/#/lucky?pass=0')
.waitForElementVisible('h2.routetitle')
.assert.textContains('h2.routetitle', 'Wild')
.assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/conditions-failed')
browser.expect.element('#currentqs').text.to.equal('')

Expand Down

0 comments on commit b8b7c05

Please sign in to comment.