Skip to content

Commit dd1ce6e

Browse files
committed
[enhancement: #14] Update example tests
1 parent fd68ffb commit dd1ce6e

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

templates/index-dom.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Index', () => {
2424
describe('once the component has been rendered', () => {
2525

2626
test('should show the proper heading', () => {
27-
expect(renderedComponent.getByText('Welcome to SvelteKit')).toBeInTheDocument();
27+
expect(renderedComponent.getByText('SvelteKit', {exact: false})).toBeInTheDocument();
2828
});
2929

3030
});

templates/index-dom.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Index', () => {
2424
describe('once the component has been rendered', () => {
2525

2626
test('should show the proper heading', () => {
27-
expect(renderedComponent.getByText('Welcome to SvelteKit')).toBeInTheDocument();
27+
expect(renderedComponent.getByText('SvelteKit', {exact: false})).toBeInTheDocument();
2828
});
2929

3030
});

templates/index.spec.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import { render } from '@testing-library/svelte';
2+
import Index from './index.svelte';
3+
4+
/**
5+
* @jest-environment jsdom
6+
*/
7+
18
/**
29
* An example test suite outlining the usage of
310
* `describe()`, `beforeEach()`, `test()` and `expect()`
@@ -7,16 +14,16 @@
714

815
describe('Index', () => {
916

10-
let isTestSuitePassing = false;
17+
let renderedComponent;
1118

1219
beforeEach(() => {
13-
isTestSuitePassing = true;
20+
renderedComponent = render(Index);
1421
});
1522

16-
describe('isTestSuitePassing', () => {
23+
describe('once the component has been rendered', () => {
1724

18-
test('should be true', () => {
19-
expect(isTestSuitePassing).toBe(true);
25+
test('should show the proper heading', () => {
26+
expect(renderedComponent.getByText('SvelteKit', {exact: false})).toBeDefined();
2027
});
2128

2229
});

templates/index.spec.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import { render, RenderResult } from '@testing-library/svelte';
2+
import Index from './index.svelte';
3+
4+
/**
5+
* @jest-environment jsdom
6+
*/
7+
18
/**
29
* An example test suite outlining the usage of
310
* `describe()`, `beforeEach()`, `test()` and `expect()`
@@ -7,16 +14,16 @@
714

815
describe('Index', () => {
916

10-
let isTestSuitePassing = false;
17+
let renderedComponent: RenderResult;
1118

1219
beforeEach(() => {
13-
isTestSuitePassing = true;
20+
renderedComponent = render(Index);
1421
});
1522

16-
describe('isTestSuitePassing', () => {
23+
describe('once the component has been rendered', () => {
1724

18-
test('should be true', () => {
19-
expect(isTestSuitePassing).toBe(true);
25+
test('should show the proper heading', () => {
26+
expect(renderedComponent.getByText('SvelteKit', {exact: false})).toBeDefined();
2027
});
2128

2229
});

0 commit comments

Comments
 (0)