From 614b9b7ef4f9c741b4163b79372ec937f72788c3 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Tue, 23 Jan 2024 17:01:06 -0500 Subject: [PATCH] add new context test --- src/__tests__/context.test.js | 14 ++++++++++++++ src/__tests__/fixtures/Context.svelte | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 src/__tests__/context.test.js create mode 100644 src/__tests__/fixtures/Context.svelte diff --git a/src/__tests__/context.test.js b/src/__tests__/context.test.js new file mode 100644 index 0000000..effdef4 --- /dev/null +++ b/src/__tests__/context.test.js @@ -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() +}) diff --git a/src/__tests__/fixtures/Context.svelte b/src/__tests__/fixtures/Context.svelte new file mode 100644 index 0000000..be8253b --- /dev/null +++ b/src/__tests__/fixtures/Context.svelte @@ -0,0 +1,7 @@ + + +
{ctx.message}