-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e71574
commit 98300a0
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,12 @@ jobs: | |
run: | | ||
npm ci | ||
npm t | ||
- name: Test & publish code coverage | ||
uses: paambaati/[email protected] | ||
env: | ||
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} | ||
with: | ||
coverageCommand: yarn run coverage | ||
coverageLocations: | | ||
${{github.workspace}}/test/coverage/lcov.info:lcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
collectCoverage: true, | ||
coverageDirectory: './test/coverage', | ||
coverageReporters: ['json', 'html', 'lcov'], | ||
collectCoverageFrom: [ | ||
'./src/**/*.{js,ts}', | ||
'./src/**/*.unit.test.ts', | ||
'!**/node_modules/**', | ||
'!**/vendor/**', | ||
'!**/vendor/**', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { GoTrueApi, Session } from '../src/index' | ||
import faker from 'faker' | ||
|
||
const GOTRUE_URL = 'http://localhost:9998' | ||
|
||
const api = new GoTrueApi({ | ||
url: GOTRUE_URL, | ||
headers: { | ||
Authorization: `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwicm9sZSI6InN1cGFiYXNlX2FkbWluIiwiaWF0IjoxNTE2MjM5MDIyfQ.0sOtTSTfPv5oPZxsjvBO249FI4S4p0ymHoIZ6H6z9Y8`, | ||
}, | ||
}) | ||
|
||
const email = `api_ac_enabled_${faker.internet.email().toLowerCase()}` | ||
const password = faker.internet.password() | ||
let validSession: Session | null = null | ||
|
||
test('signUpWithEmail()', async () => { | ||
const { error, data } = await api.signUpWithEmail(email, password, { | ||
data: { status: 'alpha' }, | ||
}) | ||
validSession = data as Session | ||
expect(error).toBeNull() | ||
expect(data).toMatchInlineSnapshot( | ||
{ | ||
access_token: expect.any(String), | ||
expires_at: expect.any(Number), | ||
refresh_token: expect.any(String), | ||
user: { | ||
id: expect.any(String), | ||
created_at: expect.any(String), | ||
email: expect.any(String), | ||
updated_at: expect.any(String), | ||
last_sign_in_at: expect.any(String), | ||
email_confirmed_at: expect.any(String), | ||
}, | ||
}, | ||
` | ||
Object { | ||
"access_token": Any<String>, | ||
"expires_at": Any<Number>, | ||
"expires_in": 3600, | ||
"refresh_token": Any<String>, | ||
"token_type": "bearer", | ||
"user": Object { | ||
"app_metadata": Object { | ||
"provider": "email", | ||
"providers": Array [ | ||
"email", | ||
], | ||
}, | ||
"aud": "", | ||
"created_at": Any<String>, | ||
"email": Any<String>, | ||
"email_confirmed_at": Any<String>, | ||
"id": Any<String>, | ||
"identities": Array [], | ||
"last_sign_in_at": Any<String>, | ||
"phone": "", | ||
"role": "", | ||
"updated_at": Any<String>, | ||
"user_metadata": Object { | ||
"status": "alpha", | ||
}, | ||
}, | ||
} | ||
` | ||
) | ||
}) | ||
|
||
test('getUser()', async () => { | ||
const { error, data } = await api.getUser(validSession?.access_token || '') | ||
expect(error).toBeNull() | ||
|
||
expect(data).toMatchInlineSnapshot( | ||
{ | ||
id: expect.any(String), | ||
created_at: expect.any(String), | ||
email: expect.any(String), | ||
updated_at: expect.any(String), | ||
last_sign_in_at: expect.any(String), | ||
email_confirmed_at: expect.any(String), | ||
confirmed_at: expect.any(String), | ||
}, | ||
` | ||
Object { | ||
"app_metadata": Object { | ||
"provider": "email", | ||
"providers": Array [ | ||
"email", | ||
], | ||
}, | ||
"aud": "", | ||
"confirmed_at": Any<String>, | ||
"created_at": Any<String>, | ||
"email": Any<String>, | ||
"email_confirmed_at": Any<String>, | ||
"id": Any<String>, | ||
"identities": Array [], | ||
"last_sign_in_at": Any<String>, | ||
"phone": "", | ||
"role": "", | ||
"updated_at": Any<String>, | ||
"user_metadata": Object { | ||
"status": "alpha", | ||
}, | ||
} | ||
` | ||
) | ||
}) |