-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
21 additions
and
6 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
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 |
---|---|---|
|
@@ -13,7 +13,6 @@ const { keys, plans } = openkey({ redis: new Redis() }) | |
|
||
test.beforeEach(async () => { | ||
const keys = await redis.keys(`${KEY_PREFIX}*`) | ||
|
||
if (keys.length > 0) await redis.del(keys) | ||
}) | ||
|
||
|
@@ -130,6 +129,20 @@ test('.update # error if key does not exist', async t => { | |
t.is(error.name, 'TypeError') | ||
}) | ||
|
||
test('.update # error if plan is invalid', async t => { | ||
const { id } = await keys.create({ name: '[email protected]' }) | ||
const error = await t.throwsAsync(keys.update(id, { plan: 'id' })) | ||
t.is(error.message, 'The id `id` must to start with `plan_`.') | ||
t.is(error.name, 'TypeError') | ||
}) | ||
|
||
test('.update # error if plan does not exist', async t => { | ||
const { id } = await keys.create({ name: '[email protected]' }) | ||
const error = await t.throwsAsync(keys.update(id, { plan: 'plan_id' })) | ||
t.is(error.message, 'The plan `plan_id` does not exist.') | ||
t.is(error.name, 'TypeError') | ||
}) | ||
|
||
test('.update # add a plan', async t => { | ||
const plan = await plans.create({ | ||
name: 'free tier', | ||
|
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