-
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.
- Loading branch information
Showing
4 changed files
with
72 additions
and
31 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
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
54 changes: 49 additions & 5 deletions
54
...ernal/Voice/internal/funcs/getJoinableStateStatus/internal/getJoinableStateStatus.spec.ts
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 |
---|---|---|
@@ -1,35 +1,79 @@ | ||
import type { VoiceBasedChannel } from '@/features/library/index.js'; | ||
|
||
import { getJoinableStateStatus } from './getJoinableStateStatus.func.js'; | ||
import { JOINABLE_STATE_STATUS } from './getJoinableStateStatus.constants.js'; | ||
|
||
describe('getJoinableStateStatus', () => { | ||
it('should return NOT_FOUND if the channel is null', () => { | ||
const result = getJoinableStateStatus({ channel: null }); | ||
|
||
expect(result).toBe('NOT_FOUND'); | ||
expect(result).toBe(JOINABLE_STATE_STATUS.NOT_FOUND); | ||
}); | ||
|
||
it('should return NOT_JOINABLE if the channel is not joinable', () => { | ||
const result = getJoinableStateStatus({ | ||
channel: { joinable: false } as VoiceBasedChannel, | ||
channel: { | ||
joinable: false, | ||
client: { guilds: { cache: new Map() } }, | ||
guildId: 'guildId', | ||
} as VoiceBasedChannel, | ||
}); | ||
|
||
expect(result).toBe('NOT_JOINABLE'); | ||
}); | ||
|
||
it('should return NOT_VIEWABLE if the channel is not viewable', () => { | ||
const result = getJoinableStateStatus({ | ||
channel: { joinable: true, viewable: false } as VoiceBasedChannel, | ||
channel: { | ||
joinable: true, | ||
viewable: false, | ||
client: { guilds: { cache: new Map() } }, | ||
guildId: 'guildId', | ||
} as VoiceBasedChannel, | ||
}); | ||
|
||
expect(result).toBe('NOT_VIEWABLE'); | ||
}); | ||
|
||
it('should return JOINABLE if the channel is joinable and viewable', () => { | ||
const result = getJoinableStateStatus({ | ||
channel: { joinable: true, viewable: true } as VoiceBasedChannel, | ||
channel: { | ||
joinable: true, | ||
viewable: true, | ||
client: { guilds: { cache: new Map() } }, | ||
guildId: 'guildId', | ||
} as VoiceBasedChannel, | ||
}); | ||
|
||
expect(result).toBe('JOINABLE'); | ||
expect(result).toBe(JOINABLE_STATE_STATUS.JOINABLE); | ||
}); | ||
|
||
it('should return undefined if the voice state is not found', () => { | ||
const result = getJoinableStateStatus({ | ||
channel: { | ||
joinable: true, | ||
viewable: true, | ||
client: { | ||
user: { id: 'userId' }, | ||
guilds: { | ||
cache: new Map([ | ||
[ | ||
'guildId', | ||
{ | ||
voiceStates: { | ||
cache: new Map([ | ||
['userId', { voiceStates: { cache: new Map() } }], | ||
]), | ||
}, | ||
}, | ||
], | ||
]), | ||
}, | ||
}, | ||
guildId: 'guildId', | ||
} as unknown as VoiceBasedChannel, | ||
}); | ||
|
||
expect(result).toBe(JOINABLE_STATE_STATUS.ALREADY_JOINED); | ||
}); | ||
}); |