Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
williamgrosset committed Aug 23, 2023
1 parent 83565cf commit c76ced2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 19 deletions.
27 changes: 26 additions & 1 deletion test/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,32 @@ export default function Home() {
</Head>

<main>
<Sparkline values={[1, 2, 1, 4, 6, 8, 6]} width={50} height={50} />
<Sparkline
values={[1, 2, 1, 4, 6, 8, 6]}
width={100}
height={100}
lineColor="#00FF00"
lineWidth={4}
fillColor="#9DFF9D"
/>

<Sparkline
values={[3, 2, 4, 3, 3, 2, 3]}
width={100}
height={100}
lineColor="#EED202"
lineWidth={4}
fillColor="#FFE900"
/>

<Sparkline
values={[4, 3, 4, 6, 5, 4, 2]}
width={100}
height={100}
lineColor="red"
lineWidth={4}
fillColor="#FF9999"
/>
</main>
</>
)
Expand Down
1 change: 1 addition & 0 deletions test/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ html,
body {
max-width: 100vw;
overflow-x: hidden;
background: #99afd7;
}

main {
Expand Down
18 changes: 0 additions & 18 deletions test/tests/example.spec.ts

This file was deleted.

27 changes: 27 additions & 0 deletions test/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test'

test.beforeEach(async ({ page }) => {
await page.goto('/')
})

test.describe('Sparkline', () => {
test('renders with width and height', async ({ page }) => {
await expect(page.locator('[data-sandbox-sparkline]').first()).toHaveCSS(
'width',
'100px'
)
await expect(page.locator('[data-sandbox-sparkline]').first()).toHaveCSS(
'height',
'100px'
)
})

test('renders line with values', async ({ page }) => {
await expect(
page.locator('[data-sandbox-sparkline] path').nth(1)
).toHaveAttribute(
'd',
'M0 92 L 0 92, L 17 83, L 33 92, L 50 67, L 67 50, L 83 33, L 100 50'
)
})
})

0 comments on commit c76ced2

Please sign in to comment.