-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(token manager): change project init errors
- Loading branch information
Showing
4 changed files
with
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as faker from "faker"; | ||
import { IAuthOptions, jexiaClient } from "../../../src/node"; | ||
|
||
describe("initialize client", () => { | ||
it("should throw an error if project id is not provided", (done) => { | ||
const options = { | ||
key: faker.random.uuid(), | ||
secret: faker.random.word(), | ||
} as IAuthOptions; | ||
|
||
jexiaClient().init(options) | ||
.then(() => done.fail("successfully initialized")) | ||
.catch(error => { | ||
expect(error.message).toEqual("Please supply a valid Jexia project ID."); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should throw an error if project is not found", (done) => { | ||
const options = { | ||
projectID: faker.random.uuid(), | ||
key: faker.random.uuid(), | ||
secret: faker.random.word(), | ||
} | ||
|
||
jexiaClient().init(options) | ||
.then(() => done.fail("successfully initialized")) | ||
.catch(error => { | ||
expect(error.message).toEqual(`Authorization failed: project ${options.projectID} not found.`); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should throw an error if credentials are incorrect", (done) => { | ||
const options = { | ||
projectID: process.env.E2E_PROJECT_ID as string, | ||
key: faker.random.uuid(), | ||
secret: faker.random.word(), | ||
} | ||
|
||
jexiaClient().init(options) | ||
.then(() => done.fail("successfully initialized")) | ||
.catch(error => { | ||
expect(error.message).toEqual(`Authorization failed: incorrect key/secret`); | ||
done(); | ||
}); | ||
}); | ||
}); |
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