-
-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alt test using each #5096
Closed
Closed
alt test using each #5096
Conversation
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
gastonfournier
commented
Oct 19, 2023
Comment on lines
1055
to
1075
await expect(async () => { | ||
await projectService.changeRole( | ||
project.id, | ||
memberRole.id, | ||
user.id, | ||
'test', | ||
test.each([ | ||
{ | ||
name: 'changeRole', | ||
fn: async (projectId: string, roleId: number, userId: number) => | ||
projectService.changeRole(projectId, roleId, userId, 'test'), | ||
}, | ||
{ | ||
name: 'setRolesForUser', | ||
fn: async (projectId: string, roleId: number, userId: number) => | ||
projectService.setRolesForUser( | ||
projectId, | ||
userId, | ||
[roleId], | ||
'test', | ||
), | ||
}, | ||
])( | ||
'should not update role for user on project when she is the owner ($name)', | ||
async ({ name, fn }) => { | ||
const project = { | ||
id: `update-users-not-allowed-${name}`, | ||
name: 'New project', | ||
description: 'Blah', | ||
mode: 'open' as const, | ||
defaultStickiness: 'clientId', | ||
}; | ||
await projectService.createProject(project, user); | ||
|
||
const memberRole = await stores.roleStore.getRoleByName( | ||
RoleName.MEMBER, | ||
); | ||
}).rejects.toThrowError( | ||
new Error('A project must have at least one owner'), | ||
); | ||
|
||
await expect(async () => { | ||
await projectService.setRolesForUser( | ||
project.id, | ||
user.id, | ||
[memberRole.id], | ||
'test', | ||
expect(() => | ||
fn(project.id, memberRole.id, user.id), | ||
).rejects.toThrowError( | ||
new Error('A project must have at least one owner'), | ||
); | ||
}).rejects.toThrowError( | ||
new Error('A project must have at least one owner'), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making 2 assertions, this splits into 2 tests using test.each
gastonfournier
force-pushed
the
ensure-projects-have-owners
branch
from
October 19, 2023 11:47
d9de330
to
b5b4fb9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have different ways of changing access to a project, this pr covers tests with different functions