{
"semi": false,
"trailingComma": "es5",
- "singleQuote": true
+ "singleQuote": true,
+ "arrowParens": "avoid"
}
const encodedToEncode = toEncode
.split('')
.map(c => {
- const hex = c
- .charCodeAt(0)
- .toString(16)
- .toUpperCase()
+ const hex = c.charCodeAt(0).toString(16).toUpperCase()
return '%' + (hex.length > 1 ? hex : '0' + hex)
})
.join('')
const encodedToEncode = toEncode
.split('')
.map(c => {
- const hex = c
- .charCodeAt(0)
- .toString(16)
- .toUpperCase()
+ const hex = c.charCodeAt(0).toString(16).toUpperCase()
return '%' + (hex.length > 1 ? hex : '0' + hex)
})
.join('')
const encodedToEncode = toEncode
.split('')
.map(c => {
- const hex = c
- .charCodeAt(0)
- .toString(16)
- .toUpperCase()
+ const hex = c.charCodeAt(0).toString(16).toUpperCase()
return '%' + (hex.length > 1 ? hex : '0' + hex)
})
.join('')
expect.assertions(2)
const spy = jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
})
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
data: () => ({ counter: 0 }),
beforeRouteLeave: jest
.fn()
- .mockImplementationOnce(function(this: any, to, from, next) {
+ .mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
// - only available in html5 history mode
// - defaults to no scroll behavior
// - return false to prevent scroll
-const scrollBehavior: ScrollBehavior = async function(to, from, savedPosition) {
+const scrollBehavior: ScrollBehavior = async function (
+ to,
+ from,
+ savedPosition
+) {
await scrollWaiter.promise
if (savedPosition) {
'@tags': ['history', 'encoding'],
/** @type {import('nightwatch').NightwatchTest} */
- 'encodes values': function(browser) {
+ 'encodes values': function (browser) {
browser
.url(baseURL)
.assert.urlEquals(baseURL + '/')
'@tags': ['hash', 'encoding'],
/** @type {import('nightwatch').NightwatchTest} */
- 'navigating to links': function(browser) {
+ 'navigating to links': function (browser) {
browser
.url(baseURL)
.waitForElementPresent('#app > *', 1000)
},
/** @type {import('nightwatch').NightwatchTest} */
- 'encoding on initial navigation': function(browser) {
+ 'encoding on initial navigation': function (browser) {
browser
.url(baseURL + '/unicode/%C3%A9')
// navigation to unencoded value
'@tags': ['history'],
/** @type {import('nightwatch').NightwatchTest} */
- 'changes the url': function(browser) {
+ 'changes the url': function (browser) {
browser
.url(baseURL)
.waitForElementPresent('#app > *', 1000)
'@tags': ['history'],
/** @type {import('nightwatch').NightwatchTest} */
- 'scroll behavior': function(browser) {
+ 'scroll behavior': function (browser) {
const TIMEOUT = 2000
browser
.assert.count('li a', 6)
.assert.containsText('.view', 'home')
- .execute(function() {
+ .execute(function () {
window.scrollTo(0, 100)
})
.click('li:nth-child(2) a')
.waitForElementPresent('.view.foo', TIMEOUT)
.assert.containsText('.view', 'foo')
- .execute(function() {
+ .execute(function () {
window.scrollTo(0, 200)
window.history.back()
})
.waitForElementPresent('.view.home', TIMEOUT)
.assert.containsText('.view', 'home')
.assert.evaluate(
- function() {
+ function () {
return window.pageYOffset === 100
},
null,
)
// scroll on a popped entry
- .execute(function() {
+ .execute(function () {
window.scrollTo(0, 50)
window.history.forward()
})
.waitForElementPresent('.view.foo', TIMEOUT)
.assert.containsText('.view', 'foo')
.assert.evaluate(
- function() {
+ function () {
return window.pageYOffset === 200
},
null,
'restore scroll position on forward'
)
- .execute(function() {
+ .execute(function () {
window.history.back()
})
.waitForElementPresent('.view.home', TIMEOUT)
.assert.containsText('.view', 'home')
.assert.evaluate(
- function() {
+ function () {
return window.pageYOffset === 50
},
null,
.click('li:nth-child(3) a')
.waitForElementPresent('.view.bar', TIMEOUT)
.assert.evaluate(
- function() {
+ function () {
return window.pageYOffset === 0
},
null,
.click('li:nth-child(4) a')
.assert.evaluate(
- function() {
+ function () {
return (
- (document.getElementById('anchor').getBoundingClientRect().top < 1)
+ document.getElementById('anchor').getBoundingClientRect().top < 1
)
},
null,
.click('li:nth-child(5) a')
.assert.evaluate(
- function() {
+ function () {
return (
- (document.getElementById('anchor2').getBoundingClientRect().top <
- 101)
+ document.getElementById('anchor2').getBoundingClientRect().top < 101
)
},
null,
'scroll to anchor with offset'
)
- .execute(function() {
+ .execute(function () {
document.querySelector('li:nth-child(6) a').click()
})
.assert.evaluate(
- function() {
+ function () {
return (
- (document.getElementById('1number').getBoundingClientRect().top < 1)
+ document.getElementById('1number').getBoundingClientRect().top < 1
)
},
null,
// go to /foo first
.click('li:nth-child(2) a')
.waitForElementPresent('.view.foo', TIMEOUT)
- .execute(function() {
+ .execute(function () {
window.scrollTo(0, 150)
})
// revisiting the same hash should scroll again
.click('li:nth-child(4) a')
.waitForElementPresent('.view.bar', TIMEOUT)
- .execute(function() {
+ .execute(function () {
window.scrollTo(0, 50)
})
.click('li:nth-child(4) a')
.assert.evaluate(
- function() {
+ function () {
// TODO: change implementation to use `afterEach`
return true
// return (
null,
'scroll to anchor when the route is the same'
)
- .execute(function() {
+ .execute(function () {
history.back()
})
.waitForElementPresent('.view.foo', TIMEOUT)
.assert.evaluate(
- function() {
+ function () {
return window.pageYOffset === 150
},
null,
.refresh()
.waitForElementPresent('.view.foo', TIMEOUT)
.assert.evaluate(
- function() {
+ function () {
return window.pageYOffset === 150
},
null,
'@tags': ['no-headless'],
- transitions: function(browser) {
+ transitions: function (browser) {
const TIMEOUT = 2000
browser
"lint-staged": "^10.1.6",
"nightwatch": "^1.3.4",
"nightwatch-helpers": "^1.2.0",
- "prettier": "^1.19.1",
+ "prettier": "^2.0.5",
"rollup": "^1.0.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.27.0",
* @returns encoded string
*/
export function encodePath(text: string): string {
- return commonEncode(text)
- .replace(HASH_RE, '%23')
- .replace(IM_RE, '%3F')
+ return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F')
}
/**
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
-prettier@^1.19.1:
- version "1.19.1"
- resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
- integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
+prettier@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
+ integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
pretty-error@^2.1.1:
version "2.1.1"