Skip to content

Commit

Permalink
fix: adds test for current user
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwicopple committed Oct 12, 2020
1 parent 4da5a9f commit 986ab36
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function App() {

useEffect(() => {
setSession(auth.currentSession)
auth.onAuthStateChange((event, session) => setSession(session))
auth.onAuthStateChange((_event, session) => setSession(session))
console.log('auth.currentUser', auth.currentUser)
}, [])

async function handleOAuthLogin(provider) {
Expand Down
2 changes: 0 additions & 2 deletions src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default class Api {
{ email, password },
{ headers: this.headers }
)
console.log('signUpWithEmail data', data)
return { data, error: null }
} catch (error) {
console.log('signUpWithEmail error', error)
Expand All @@ -44,7 +43,6 @@ export default class Api {
{ email, password },
{ headers: this.headers }
)
console.log('signInWithEmaildata', data)
return { data, error: null }
} catch (error) {
return { data: null, error }
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from 'cross-fetch';
import fetch from 'cross-fetch'

export interface FetchOptions {
headers?: {
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/client.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Object {
}
`;
exports[`signIn() with the wrong password 1`] = `"Invalid Password"`;
exports[`signOut 1`] = `true`;
exports[`signUp() 1`] = `
Expand Down
9 changes: 9 additions & 0 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,12 @@ test('Get user after logging out', async () => {
let res = await auth.user()
expect(res).toMatchSnapshot()
})

test('signIn() with the wrong password', async () => {
let { error, data } = await auth.signIn({
email,
password: password + '2',
})
expect(error.message).toMatchSnapshot()
expect(data).toBeNull()
})

0 comments on commit 986ab36

Please sign in to comment.