Skip to content

Commit

Permalink
add new context test
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Jan 23, 2024
1 parent c0ff791 commit 614b9b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/__tests__/context.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from 'vitest'

import { render } from '..'
import Comp from './fixtures/Context.svelte'

test('can set a context', () => {
const message = 'Got it'

const { getByText } = render(Comp, {
context: new Map(Object.entries({ foo: { message } })),
})

expect(getByText(message)).toBeTruthy()
})
7 changes: 7 additions & 0 deletions src/__tests__/fixtures/Context.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import { getContext } from 'svelte';
const ctx = getContext('foo');
</script>

<div>{ctx.message}</div>

0 comments on commit 614b9b7

Please sign in to comment.