|
| 1 | +require('dotenv').config() |
| 2 | +import { createClient } from '../../src' |
1 | 3 | const chai = require('chai')
|
2 | 4 | const expect = chai.expect
|
3 | 5 | const assert = chai.assert
|
4 | 6 | chai.use(require('chai-as-promised'))
|
5 | 7 |
|
6 |
| -import { createClient } from '../../src' |
| 8 | +const SUPABASE_URL = process.env.SUPABASE_URL || 'http://localhost:1234' |
| 9 | +const SUPABASE_KEY = process.env.SUPABASE_KEY || 'examplekey' |
| 10 | + |
| 11 | +console.log('SUPABASE_KEY', SUPABASE_KEY) |
7 | 12 |
|
8 | 13 | describe('test signing up and logging in as a new user', () => {
|
9 | 14 | const supabase = createClient(
|
10 |
| - 'https://HPPNcyqrPOIDwqzQHjRl.supabase.net', |
11 |
| - 'JBkDpEMQw9a9yIeVuFhTt5JEhGjQEY' |
| 15 | + 'https://nuaqAUDnliweFqRoinst.supabase.net', |
| 16 | + 'ucHLLNUUFXVn2o6pRCcQOW82KF0RAs' |
12 | 17 | )
|
13 | 18 | const randomEmail = `a${Math.random()}@google.com`
|
14 | 19 |
|
15 | 20 | it('should register a new user', async () => {
|
16 |
| - const response = await supabase.auth.signup(randomEmail, '11password') |
17 |
| - assert(response.email === randomEmail, 'user could not sign up') |
| 21 | + try { |
| 22 | + const response = await supabase.auth.signup(randomEmail, '11password') |
| 23 | + console.log('response', response) |
| 24 | + const {body:countries} = await supabase.from('countries').select('*').limit(1) |
| 25 | + console.log('countries', countries) |
| 26 | + assert(response.email === randomEmail, 'user could not sign up') |
| 27 | + } catch (error) { |
| 28 | + // console.log('error', error) |
| 29 | + assert(!error, 'sign up returns an error') |
| 30 | + } |
18 | 31 | })
|
19 | 32 |
|
20 | 33 | it('should log in a user and return an access token', async () => {
|
21 |
| - const response = await supabase.auth.login(randomEmail, '11password') |
22 |
| - assert(response.body.access_token !== undefined, 'user could not log in') |
| 34 | + try { |
| 35 | + const response = await supabase.auth.login(randomEmail, '11password') |
| 36 | + assert(response.body.access_token !== undefined, 'user could not log in') |
| 37 | + } catch (error) { |
| 38 | + // console.log('error', error) |
| 39 | + assert(!error, 'log in returns an error') |
| 40 | + } |
23 | 41 | })
|
24 | 42 |
|
25 | 43 | it('should return the currently logged in user', async () => {
|
26 |
| - const user = await supabase.auth.user() |
27 |
| - assert(user.email === randomEmail, 'user could not be retrieved') |
| 44 | + try { |
| 45 | + const user = await supabase.auth.user() |
| 46 | + assert(user.email === randomEmail, 'user could not be retrieved') |
| 47 | + } catch (error) { |
| 48 | + // console.log('error', error) |
| 49 | + assert(!error, 'logged in user returns an error') |
| 50 | + } |
28 | 51 | })
|
29 | 52 |
|
30 | 53 | it('should logout and invalidate the previous access_token', async () => {
|
|
0 commit comments