-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle permissions for the super-user (#727)
- Loading branch information
1 parent
7e56635
commit c9549be
Showing
6 changed files
with
73 additions
and
0 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
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,59 @@ | ||
import { Channel, Client } from '../src'; | ||
import { waitABit } from './utils/wait-a-bit'; | ||
|
||
describe('Manages server as the super-user (e2e)', () => { | ||
let client: Client; | ||
|
||
beforeAll(async () => { | ||
client = new Client({ | ||
host: 'localhost', | ||
port: 64738, | ||
username: 'superuser', | ||
password: '123456', | ||
rejectUnauthorized: false, | ||
}); | ||
await client.connect(); | ||
await waitABit(1000); | ||
}); | ||
|
||
afterAll(async () => { | ||
await waitABit(1000); | ||
client.disconnect(); | ||
}); | ||
|
||
it('should create channels', async () => { | ||
let channelCreatedEventEmitted = false; | ||
client.once('channelCreate', (channel: Channel) => { | ||
expect(channel.name).toEqual('sub10'); | ||
channelCreatedEventEmitted = true; | ||
}); | ||
|
||
expect(client.user?.channel).toBeTruthy(); | ||
const channel = client.user!.channel; | ||
expect(channel).toBeTruthy(); | ||
const sub1 = await channel.createSubChannel('sub10'); | ||
expect(sub1.parent).toEqual(channel.id); | ||
expect(channelCreatedEventEmitted).toBe(true); | ||
|
||
const sub2 = await sub1.createSubChannel('sub11'); | ||
expect(sub2.parent).toEqual(sub1.id); | ||
}); | ||
|
||
it('should remove channels', async () => { | ||
let channelRemoveEventEmitted = false; | ||
|
||
client.once('channelRemove', (channel: Channel) => { | ||
expect(channel.name).toEqual('sub11'); | ||
channelRemoveEventEmitted = true; | ||
}); | ||
|
||
const sub2 = client.channels.byName('sub11'); | ||
await sub2?.remove(); | ||
expect(client.channels.byName('sub11')).toBe(undefined); | ||
expect(channelRemoveEventEmitted).toBe(true); | ||
|
||
const sub1 = client.channels.byName('sub10'); | ||
await sub1?.remove(); | ||
expect(client.channels.byName('sub10')).toBe(undefined); | ||
}); | ||
}); |
Binary file not shown.
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