Skip to content

Commit

Permalink
add box shadow inset test and strictly equals
Browse files Browse the repository at this point in the history
  • Loading branch information
dgeare committed Jun 17, 2019
1 parent 538d365 commit c04eaf6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
43 changes: 21 additions & 22 deletions app/features/boxshadow.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava'

import { setupPptrTab, teardownPptrTab, changeMode, getActiveTool }
import { setupPptrTab, teardownPptrTab, changeMode, getActiveTool, pptrMetaKey }
from '../../tests/helpers'

const tool = 'boxshadow'
Expand All @@ -12,9 +12,8 @@ const getShadowValues = async (page, testEl = test_selector) => {
}

const parseShadowValues = (str) => {
const [,color,x,y,blur,spread,inset] = /([^\)]+\)) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)( inset)?/.exec(str)

return { color, x, y, blur, spread, inset : inset !== undefined }
const [,color,x,y,blur,spread,inset] = /([^\)]+\)) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)( inset)?/.exec(str)
return { color, x, y, blur, spread, inset : inset !== undefined }
}

test.beforeEach(async t => {
Expand All @@ -38,12 +37,12 @@ test('Can adjust X position', async t => {
await page.click(test_selector)
await page.keyboard.press('ArrowRight')
let shadow = await getShadowValues(page)
t.true(shadow.x == "1px")
t.true(shadow.x === "1px")
//test shift case
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowRight')
shadow = await getShadowValues(page)
t.true(shadow.x == "11px")
t.true(shadow.x === "11px")

t.pass()
})
Expand All @@ -55,12 +54,12 @@ test('Can adjust Y position', async t => {
await page.click(test_selector)
await page.keyboard.press('ArrowDown')
let shadow = await getShadowValues(page)
t.true(shadow.y == "1px")
t.true(shadow.y === "1px")
//test shift case
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowDown')
shadow = await getShadowValues(page)
t.true(shadow.y == "11px")
t.true(shadow.y === "11px")

t.pass()
})
Expand All @@ -73,12 +72,12 @@ test('Shadow Blur Works', async t => {
await page.keyboard.down('Alt')
await page.keyboard.press('ArrowUp')
let shadow = await getShadowValues(page)
t.true(shadow.blur == "1px")
t.true(shadow.blur === "1px")
//test shift case
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowUp')
shadow = await getShadowValues(page)
t.true(shadow.blur == "11px")
t.true(shadow.blur === "11px")

t.pass()
})
Expand All @@ -91,28 +90,28 @@ test('Shadow Spread Works', async t => {
await page.keyboard.down('Alt')
await page.keyboard.press('ArrowRight')
let shadow = await getShadowValues(page)
t.true(shadow.spread == "1px")
t.true(shadow.spread === "1px")
//test shift case
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowRight')
shadow = await getShadowValues(page)
t.true(shadow.spread == "11px")
t.true(shadow.spread === "11px")

t.pass()
})

// test('Shadow can be set to inset', async t => {
// const { page } = t.context
test('Shadow can be set to inset', async t => {
const { page } = t.context

// await page.click(test_selector)
// await page.keyboard.press('ArrowDown')
// await page.keyboard.down('Control')
// await page.keyboard.press('ArrowDown')
// const shadow = await getShadowValues(page)
// t.true(shadow.inset)
await page.click(test_selector)
await page.keyboard.press('ArrowDown')
await page.keyboard.down(await pptrMetaKey(page))
await page.keyboard.press('ArrowDown')
const shadow = await getShadowValues(page)
t.true(shadow.inset)

// t.pass()
// })
t.pass()
})


test.afterEach(teardownPptrTab)
16 changes: 8 additions & 8 deletions app/features/flex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ test('Can adjust justify-content', async t => {
await page.click(test_selector)
await page.keyboard.press('ArrowRight')
let justifyStr = await page.$eval(test_selector, el => el.style.justifyContent)
t.true(justifyStr == "center")
t.true(justifyStr === "center")

await page.keyboard.press('ArrowRight')
justifyStr = await page.$eval(test_selector, el => el.style.justifyContent)
t.true(justifyStr == "flex-end")
t.true(justifyStr === "flex-end")

await page.keyboard.press('ArrowLeft')
await page.keyboard.press('ArrowLeft')
justifyStr = await page.$eval(test_selector, el => el.style.justifyContent)
t.true(justifyStr == "flex-start")
t.true(justifyStr === "flex-start")

t.pass()
})
Expand All @@ -52,16 +52,16 @@ test('Can adjust align-items', async t => {
await page.click(test_selector)
await page.keyboard.press('ArrowDown')
let alignStr = await page.$eval(test_selector, el => el.style.alignItems)
t.true(alignStr == "center")
t.true(alignStr === "center")

await page.keyboard.press('ArrowDown')
alignStr = await page.$eval(test_selector, el => el.style.alignItems)
t.true(alignStr == "flex-end")
t.true(alignStr === "flex-end")

await page.keyboard.press('ArrowUp')
await page.keyboard.press('ArrowUp')
alignStr = await page.$eval(test_selector, el => el.style.alignItems)
t.true(alignStr == "flex-start")
t.true(alignStr === "flex-start")

t.pass()
})
Expand All @@ -74,7 +74,7 @@ test('Can apply space-around', async t => {
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowLeft')
let justifyStr = await page.$eval(test_selector, el => el.style.justifyContent)
t.true(justifyStr == "space-around")
t.true(justifyStr === "space-around")

t.pass()
})
Expand All @@ -87,7 +87,7 @@ test('Can apply space-between', async t => {
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowRight')
let justifyStr = await page.$eval(test_selector, el => el.style.justifyContent)
t.true(justifyStr == "space-between")
t.true(justifyStr === "space-between")

t.pass()
})
Expand Down
10 changes: 5 additions & 5 deletions app/features/position.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ test('Test Nudge Up/Down Works', async t => {

await page.keyboard.press('ArrowUp')
const changedPageTop = await page.$eval(test_selector, el => el.getBoundingClientRect().top)
t.true(originalPageTop - 1 == changedPageTop)
t.true(originalPageTop - 1 === changedPageTop)

await page.keyboard.press('ArrowDown')
await page.keyboard.press('ArrowDown')
const finalPageTop = await page.$eval(test_selector, el => el.getBoundingClientRect().top)
t.true(originalPageTop + 1 == finalPageTop)
t.true(originalPageTop + 1 === finalPageTop)

t.pass()
})
Expand All @@ -47,12 +47,12 @@ test('Test Nudge Left/Right Works', async t => {

await page.keyboard.press('ArrowLeft')
const changedPageLeft = await page.$eval(test_selector, el => el.getBoundingClientRect().left)
t.true(originalPageLeft - 1 == changedPageLeft)
t.true(originalPageLeft - 1 === changedPageLeft)

await page.keyboard.press('ArrowRight')
await page.keyboard.press('ArrowRight')
const finalPageLeft = await page.$eval(test_selector, el => el.getBoundingClientRect().left)
t.true(originalPageLeft + 1 == finalPageLeft)
t.true(originalPageLeft + 1 === finalPageLeft)

t.pass()
})
Expand All @@ -65,7 +65,7 @@ test('Test Shift Nudge Up/Down Works', async t => {
await page.keyboard.down("Shift")
await page.keyboard.press('ArrowUp')
const changedPageTop = await page.$eval(test_selector, el => el.getBoundingClientRect().top)
t.true(originalPageTop - 10 == changedPageTop)
t.true(originalPageTop - 10 === changedPageTop)
t.pass()
})

Expand Down
2 changes: 1 addition & 1 deletion app/features/text.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test('Can delete text content', async t => {

const now = await page.$eval(test_selector, el => el.innerHTML)

t.true(original.length == now.length + 2)
t.true(original.length === now.length + 2)

t.pass()
})
Expand Down
5 changes: 5 additions & 0 deletions tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ export const changeMode = async ({page, tool}) =>
export const getActiveTool = async page =>
await page.$eval('vis-bug', el =>
el.activeTool)

export const pptrMetaKey = async page => {
let isMac = await page.evaluate(_ => window.navigator.platform.includes('Mac'))
return isMac ? "Meta" : "Control"
}

0 comments on commit c04eaf6

Please sign in to comment.