Skip to content

Commit

Permalink
test: address TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Aug 19, 2022
1 parent 770009b commit fb60913
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion __tests__/cmds/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,21 @@ describe('rdme login', () => {
mock.done();
});

it.todo('should error if trying to access a project that is not yours');
it('should error if trying to access a project that is not yours', async () => {
const projectThatIsNotYours = 'unauthorized-project';
prompts.inject([email, password, projectThatIsNotYours]);
const errorResponse = {
error: 'PROJECT_NOTFOUND',
message: `The project (${projectThatIsNotYours}) can't be found.`,
suggestion: `The project is referred to as your \`subdomain\` in the dashboard when you're looking for it. If you're sure it exists, maybe you don't have access to it? You can check if it exists here: https://${projectThatIsNotYours}.readme.io.`,
help: 'If you need help, email support@readme.io',
};

const mock = getAPIMock()
.post('/api/v1/login', { email, password, project: projectThatIsNotYours })
.reply(404, errorResponse);

await expect(cmd.run({})).rejects.toStrictEqual(new APIError(errorResponse));
mock.done();
});
});

0 comments on commit fb60913

Please sign in to comment.