This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: use live sandbox client for tests
- Loading branch information
1 parent
3531e46
commit 0975e41
Showing
6 changed files
with
144 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,39 @@ | ||
import * as Ably from 'ably'; | ||
import { Types } from 'ably'; | ||
import got from 'got'; | ||
|
||
export class TestApp { | ||
id: string; | ||
key: string; | ||
|
||
static async create() { | ||
const url = 'https://sandbox-rest.ably.io/apps'; | ||
const body = { keys: [{}] }; | ||
|
||
const res: { | ||
appId: string; | ||
keys: { keyStr: string }[]; | ||
} = await got.post(url, { json: body }).json(); | ||
|
||
return new TestApp(res.appId, res.keys[0].keyStr); | ||
} | ||
|
||
constructor(id: string, key: string) { | ||
this.id = id; | ||
this.key = key; | ||
} | ||
|
||
client(clientId?: string): Types.RealtimePromise { | ||
return new Ably.Realtime.Promise({ | ||
key: this.key, | ||
environment: 'sandbox', | ||
clientId: clientId || null, | ||
}); | ||
} | ||
|
||
delete() { | ||
return got.delete( | ||
`https://sandbox-rest.ably.io/apps/${this.id}?key=${this.key}` | ||
); | ||
} | ||
} |