|
1 | | -import { redactDevice } from 'index.js' |
| 1 | +import { createDevice, redactDevice } from 'index.js' |
2 | 2 | import { setup as setupUsers } from 'util/testing/index.js' |
3 | 3 | import { describe, expect, it } from 'vitest' |
4 | 4 |
|
@@ -41,6 +41,26 @@ describe('Team', () => { |
41 | 41 | expect(tryToRemoveDevice).toThrowError() |
42 | 42 | }) |
43 | 43 |
|
| 44 | + it("doesn't remove other devices with the same name", () => { |
| 45 | + const { alice } = setup() |
| 46 | + |
| 47 | + // Alice already has a device called 'laptop' |
| 48 | + const firstLaptop = alice.device |
| 49 | + expect(firstLaptop.deviceName).toBe('laptop') |
| 50 | + expect(alice.team.members(alice.userId).devices).toHaveLength(1) |
| 51 | + |
| 52 | + // Alice adds a second device also called 'laptop' |
| 53 | + const secondLaptop = createDevice({ userId: alice.userId, deviceName: 'laptop' }) |
| 54 | + alice.team.addForTesting(alice.user, [], redactDevice(secondLaptop)) |
| 55 | + expect(alice.team.members(alice.userId).devices).toHaveLength(2) |
| 56 | + |
| 57 | + // Alice removes the first laptop |
| 58 | + alice.team.removeDevice(alice.device.deviceId) |
| 59 | + |
| 60 | + // The second laptop is still there |
| 61 | + expect(alice.team.members(alice.userId).devices).toHaveLength(1) |
| 62 | + }) |
| 63 | + |
44 | 64 | it('deviceWasRemoved works as expected', () => { |
45 | 65 | const { alice, bob } = setup() |
46 | 66 | alice.team.removeDevice(bob.device.deviceId) |
|
0 commit comments