|
@@ -3,8 +3,33 @@ import { render, cleanup } from '@testing-library/svelte'
|
|
|
beforeEach(cleanup)
|
|
|
describe('App', () => {
|
|
|
test('should render greeting', () => {
|
|
|
- const { getByText } = render(App, { props: {} })
|
|
|
+ const { getByText } = render(App, { props: {name: "world"}})
|
|
|
expect(getByText('Hello world!'))
|
|
|
})
|
|
|
|
|
|
+ test('two plus two', () => {
|
|
|
+ const value = 2 + 2;
|
|
|
+ expect(value).toBeGreaterThan(3);
|
|
|
+ expect(value).toBeGreaterThanOrEqual(3.5);
|
|
|
+ expect(value).toBeLessThan(5);
|
|
|
+ expect(value).toBeLessThanOrEqual(4.5);
|
|
|
+
|
|
|
+ // toBe and toEqual are equivalent for numbers
|
|
|
+ expect(value).toBe(4);
|
|
|
+ expect(value).toEqual(4);
|
|
|
+ })
|
|
|
+
|
|
|
+ test('should change button text after click', async () => {
|
|
|
+ const { getByText } = render(App, { props: { name: 'world' } })
|
|
|
+ expect(getByText('Hello world!'))
|
|
|
+
|
|
|
+ fireEvent.click(getByText('Clicked 0 times'))
|
|
|
+
|
|
|
+ const button = await waitForElement(() => getByText('Clicked 1 times'))
|
|
|
+
|
|
|
+ expect(button).toBeInTheDocument()
|
|
|
+ })
|
|
|
+
|
|
|
})
|
|
|
+
|
|
|
+
|