Skip to content

Commit 0cda745

Browse files
committed
test: add tests for core features
1 parent 0bca77c commit 0cda745

22 files changed

+218
-136
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ node_modules
99
vite.config.js.timestamp-*
1010
vite.config.ts.timestamp-*
1111
package
12+
/test-results

dist/components/SignedIn.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ const user = userStore();
66
</script>
77

88
{#if $user}
9-
<slot user={$user} signOut={() => signOut(auth)} />
9+
<slot user={$user} {auth} signOut={() => signOut(auth)} />
1010
{/if}

dist/components/SignedIn.svelte.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SvelteComponent } from "svelte";
2-
import { signOut, type User } from "firebase/auth";
2+
import { signOut, type User, type Auth } from "firebase/auth";
33
declare const __propDef: {
44
props: Record<string, never>;
55
events: {
@@ -8,6 +8,7 @@ declare const __propDef: {
88
slots: {
99
default: {
1010
user: User;
11+
auth: Auth;
1112
signOut: () => Promise<void>;
1213
};
1314
};

dist/components/SignedOut.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
<script>import { userStore } from "../stores/auth.js";
1+
<script>import { getFirebaseContext } from "../stores/sdk.js";
2+
import { userStore } from "../stores/auth.js";
3+
getFirebaseContext;
4+
const auth = getFirebaseContext().auth;
25
const user = userStore();
36
</script>
47

58
{#if !$user}
6-
<slot />
9+
<slot {auth} />
710
{/if}

dist/components/SignedOut.svelte.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { SvelteComponent } from "svelte";
2+
import type { Auth } from 'firebase/auth';
23
declare const __propDef: {
34
props: Record<string, never>;
45
events: {
56
[evt: string]: CustomEvent<any>;
67
};
78
slots: {
8-
default: {};
9+
default: {
10+
auth: Auth;
11+
};
912
};
1013
};
1114
export type SignedOutProps = typeof __propDef.props;

dist/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ import SignedIn from './components/SignedIn.svelte';
77
import { docStore } from './stores/firestore.js';
88
import { collectionStore } from './stores/firestore.js';
99
import { userStore } from './stores/auth.js';
10-
export { Doc, User, Collection, FirebaseApp, SignedOut, SignedIn, docStore, collectionStore, userStore };
10+
import { getFirebaseContext } from './stores/sdk.js';
11+
export { Doc, User, Collection, FirebaseApp, SignedOut, SignedIn, docStore, collectionStore, userStore, getFirebaseContext };

dist/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import Doc from './components/Doc.svelte';
55
import FirebaseApp from './components/FirebaseApp.svelte';
66
import SignedIn from './components/SignedIn.svelte';
77
import SignedOut from './components/SignedOut.svelte';
8-
// import { docStore, collectionStore } from './stores/stores.js';
98
import { userStore } from './stores/auth.js';
109
import { docStore, collectionStore } from './stores/firestore.js';
11-
10+
import { getFirebaseContext } from './stores/sdk.js';
11+
1212
export {
1313
Doc,
1414
User,
@@ -18,5 +18,6 @@ export {
1818
SignedIn,
1919
docStore,
2020
collectionStore,
21-
userStore
21+
userStore,
22+
getFirebaseContext
2223
}

dist/stores/firestore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function collectionStore(ref, startWith = []) {
8686
/**
8787
* experimental, fetch document based on curret user
8888
*/
89-
export function userDataStore(collectionPath = 'users') {
89+
export function userDataStore(collectionPath = "users") {
9090
const user = userStore();
9191
return derived(user, ($user, set) => {
9292
if (!$user)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"preview": "vite preview",
88
"package": "svelte-kit sync && svelte-package && publint",
99
"prepublishOnly": "npm run package",
10-
"test": "playwright test",
10+
"test": "playwright test --ui",
1111
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1212
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1313
"lint": "eslint ."

src/lib/components/SignedIn.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script lang="ts">
22
import { userStore } from "$lib/stores/auth.js";
33
import { getFirebaseContext } from "$lib/stores/sdk.js";
4-
import { signOut, type User } from "firebase/auth";
5-
6-
interface $$Slots {
7-
default: { user: User, signOut: () => Promise<void> }
8-
}
4+
import { signOut, type User, type Auth } from "firebase/auth";
95
106
const auth = getFirebaseContext().auth!;
117
const user = userStore()
128
9+
interface $$Slots {
10+
default: { user: User, auth: Auth, signOut: () => Promise<void> }
11+
}
12+
1313
</script>
1414

1515
{#if $user}
16-
<slot user={$user} signOut={() => signOut(auth)} />
16+
<slot user={$user} {auth} signOut={() => signOut(auth)} />
1717
{/if}

0 commit comments

Comments
 (0)