Skip to content

Commit

Permalink
Start fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Jan 25, 2023
1 parent bcbd20c commit 3d2d665
Showing 1 changed file with 19 additions and 45 deletions.
64 changes: 19 additions & 45 deletions packages/web-app-admin-settings/tests/unit/views/Users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const getDefaultUser = () => {
memberOf: [],
mail: 'admin@example.org',
drive: {
name: 'any'
id: '1',
name: 'admin',
quota: { remaining: 5000000000, state: 'normal', total: 5000000000, used: 0 }
},
appRoleAssignments: [
{
Expand Down Expand Up @@ -141,28 +143,18 @@ describe('Users view', () => {
appRoleAssignments: [
{
appRoleId: '2',
id: '1',
principalId: '1',
principalType: 'User',
resourceDisplayName: 'ownCloud Infinite Scale',
resourceId: 'some-graph-app-id'
resourceId: 'some-graph-app-id',
principalId: '1'
}
],
displayName: 'administrator',
givenName: 'Admin',
id: '1',
mail: 'administrator@example.org',
memberOf: [],
onPremisesSamAccountName: 'admin',
surname: 'Admin',
drive: {
id: '1',
name: 'Admin',
name: 'admin',
quota: {
remaining: 5000000000,
state: 'normal',
total: 5000000000,
used: 0
total: 1000000000
}
},
passwordProfile: {
Expand All @@ -176,13 +168,8 @@ describe('Users view', () => {
graph.drives.updateDrive.mockImplementation(() =>
mockAxiosResolve({
id: '1',
name: 'Admin',
quota: {
remaining: 5000000000,
state: 'normal',
total: 5000000000,
used: 0
}
name: 'admin',
quota: { remaining: 1000000000, state: 'normal', total: 1000000000, used: 0 }
})
)
graph.users.getUser.mockImplementation(() =>
Expand All @@ -200,15 +187,9 @@ describe('Users view', () => {
displayName: 'administrator',
drive: {
id: '1',
name: 'Admin',
quota: {
remaining: 5000000000,
state: 'normal',
total: 5000000000,
used: 0
}
name: 'admin',
quota: { remaining: 1000000000, state: 'normal', total: 1000000000, used: 0 }
},
givenName: 'Admin',
id: '1',
mail: 'administrator@example.org',
memberOf: [],
Expand All @@ -224,9 +205,9 @@ describe('Users view', () => {
{
...getDefaultUser(),
quota: {
remaining: 100000000,
remaining: 1000000000,
state: 'normal',
total: 100000000,
total: 1000000000,
used: 0
}
}
Expand All @@ -245,20 +226,13 @@ describe('Users view', () => {
await wrapper.vm.editUser({ user: wrapper.vm.selectedUsers[0], editUser })
await wrapper.vm.$nextTick()

console.log(wrapper.vm.users)
console.log('USER IS THERE')
console.log(wrapper.vm.users.find((user) => user.id === editUser.id))
const a = wrapper.vm.users.find((user) => user.id === editUser.id)
console.log(a)
console.log('USER IS THERE')

console.log(JSON.stringify({ ...a }))
const updatedUser = wrapper.vm.users.find((user) => user.id === editUser.id)

expect(a).toEqual(3)
expect(busStub).toHaveBeenCalledWith([
'sidebar.entity.saved',
'app.admin-settings.users.user.updated '
])
expect(updatedUser.displayName).toEqual('administrator')
expect(updatedUser.mail).toEqual('administrator@example.org')
expect(updatedUser.appRoleAssignments[0].appRoleId).toEqual('2')
expect(updatedUser.drive.quota.total).toEqual(1000000000)
expect(busStub).toHaveBeenCalledTimes(2)
expect(graphUpdateDriveStub).toHaveBeenCalled()
expect(updateSpaceFieldStub).toHaveBeenCalled()
expect(graphUpdateCreateUserAppRoleAssignmentStub).toHaveBeenCalled()
Expand Down

0 comments on commit 3d2d665

Please sign in to comment.