From e875bcfb07117cccc2c0d3b89fb8330ff1ff2525 Mon Sep 17 00:00:00 2001 From: Sanggu Date: Wed, 30 Dec 2020 12:10:01 +0900 Subject: [PATCH] feat(header): implement basic header need to implement setting / search later implement #8 --- src/App.svelte | 3 ++ src/container/Header.svelte | 76 +++++++++++++++++++++++++++++++++++ test/container/Header.test.js | 66 ++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 src/container/Header.svelte create mode 100644 test/container/Header.test.js diff --git a/src/App.svelte b/src/App.svelte index 28e81b2..ad3f6c1 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,4 +1,6 @@ @@ -24,6 +26,7 @@ } +

Hello {name}!

diff --git a/src/container/Header.svelte b/src/container/Header.svelte new file mode 100644 index 0000000..a145d3d --- /dev/null +++ b/src/container/Header.svelte @@ -0,0 +1,76 @@ + + + + +

+
+ + +
Panoptes
+ +
Settings
+
+
diff --git a/test/container/Header.test.js b/test/container/Header.test.js new file mode 100644 index 0000000..2243169 --- /dev/null +++ b/test/container/Header.test.js @@ -0,0 +1,66 @@ +import { render } from '@testing-library/svelte'; +import Header from '../../src/container/Header.svelte'; + +describe('Render Header', () => { + it('should render search, title, setting', async () => { + const { getByTestId } = render(Header); + + const title = getByTestId('title'); + const search = getByTestId('search'); + const settings = getByTestId('settings'); + + expect(title).toBeVisible(); + expect(search).toBeVisible(); + expect(settings).toBeVisible(); + }); + + it('should render search, title, setting sequentially', async () => { + const { getByTestId } = render(Header); + + const title = getByTestId('title'); + const search = getByTestId('search'); + const settings = getByTestId('settings'); + + expect(search.nextElementSibling).toEqual(title); + expect(title.nextElementSibling).toEqual(settings); + }); + + it('should render title w/ 64px bold, others w/ 24px light', async () => { + const { getByTestId } = render(Header); + + const title = getByTestId('title'); + const search = getByTestId('search'); + const settings = getByTestId('settings'); + + expect(title).toHaveStyle({ + 'font-size': '64px', + 'font-weight': 700, + }); + expect(search).toHaveStyle({ + 'font-size': '24px', + 'font-weight': 300, + }); + expect(settings).toHaveStyle({ + 'font-size': '24px', + 'font-weight': 300, + }); + }); + + it('should render search, title, settings at vertically center', async () => { + const { getByTestId } = render(Header); + + const title = getByTestId('title'); + const search = getByTestId('search'); + const settings = getByTestId('settings'); + + expect(title).toHaveStyle({ + margin: 'auto 0', + }); + expect(search).toHaveStyle({ + margin: 'auto 0', + }); + expect(settings).toHaveStyle({ + margin: 'auto 0', + }); + }); +});