This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: setup jest, add some very basic tests for the Clerk object
- Loading branch information
1 parent
82c5354
commit c5e7539
Showing
7 changed files
with
972 additions
and
26 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
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,12 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>/src" | ||
], | ||
"testMatch": [ | ||
"**/test/**/*.+(ts|tsx|js)", | ||
"**/?(*.)+(spec|test).+(ts|tsx|js)" | ||
], | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
} |
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
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
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,78 @@ | ||
import Clerk from '../Clerk'; | ||
import { ClientApi } from '../apis/ClientApi'; | ||
import { EmailApi } from '../apis/EmailApi'; | ||
import { SessionApi } from '../apis/SessionApi'; | ||
import { SMSMessageApi } from '../apis/SMSMessageApi'; | ||
import { UserApi } from '../apis/UserApi'; | ||
|
||
test('getInstance() getter returns a Clerk instance', () => { | ||
const clerk = Clerk.getInstance(); | ||
expect(clerk).toBeInstanceOf(Clerk); | ||
}); | ||
|
||
test('getInstance() always returns the same instance', () => { | ||
const clerk = Clerk.getInstance(); | ||
const clerk2 = Clerk.getInstance(); | ||
expect(clerk2).toBe(clerk); | ||
}); | ||
|
||
test('separate Clerk instances are not the same object', () => { | ||
const clerk = new Clerk(); | ||
const clerk2 = new Clerk(); | ||
expect(clerk2).not.toBe(clerk); | ||
}); | ||
|
||
test('clients getter returns a Client API instance', () => { | ||
const clients = Clerk.getInstance().clients; | ||
expect(clients).toBeInstanceOf(ClientApi); | ||
}); | ||
|
||
test('clients getter returns the same instance every time', () => { | ||
const clients = Clerk.getInstance().clients; | ||
const clients2 = Clerk.getInstance().clients; | ||
expect(clients2).toBe(clients); | ||
}); | ||
|
||
test('emails getter returns a Email API instance', () => { | ||
const emails = Clerk.getInstance().emails; | ||
expect(emails).toBeInstanceOf(EmailApi); | ||
}); | ||
|
||
test('emails getter returns the same instance every time', () => { | ||
const emails = Clerk.getInstance().emails; | ||
const emails2 = Clerk.getInstance().emails; | ||
expect(emails2).toBe(emails); | ||
}); | ||
|
||
test('sessions getter returns a Session API instance', () => { | ||
const sessions = Clerk.getInstance().sessions; | ||
expect(sessions).toBeInstanceOf(SessionApi); | ||
}); | ||
|
||
test('sessions getter returns the same instance every time', () => { | ||
const sessions = Clerk.getInstance().sessions; | ||
const sessions2 = Clerk.getInstance().sessions; | ||
expect(sessions2).toBe(sessions); | ||
}); | ||
|
||
test('smsMessages getter returns an smsMessage API instance', () => { | ||
const smsMessages = Clerk.getInstance().smsMessages; | ||
expect(smsMessages).toBeInstanceOf(SMSMessageApi); | ||
}); | ||
|
||
test('smsMessages getter returns the same instance every time', () => { | ||
const smsMessages = Clerk.getInstance().smsMessages; | ||
const smsMessages2 = Clerk.getInstance().smsMessages; | ||
expect(smsMessages2).toBe(smsMessages); | ||
}); | ||
|
||
test('users getter returns a User api instance', () => { | ||
const users = Clerk.getInstance().users; | ||
expect(users).toBeInstanceOf(UserApi); | ||
}); | ||
|
||
test('users getter returns the same instance every time', () => { | ||
const users = Clerk.getInstance().users; | ||
const users2 = Clerk.getInstance().users; | ||
expect(users2).toBe(users); | ||
}); |
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
Oops, something went wrong.