-
Notifications
You must be signed in to change notification settings - Fork 24
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
1 parent
8850fcd
commit e10ce17
Showing
2 changed files
with
52 additions
and
7 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,42 @@ | ||
// Copyright 2020 Las Venturas Playground. All rights reserved. | ||
// Use of this source code is governed by the MIT license, a copy of which can | ||
// be found in the LICENSE file. | ||
|
||
import MockPlaygroundCommands from 'features/playground/test/mock_playground_commands.js'; | ||
|
||
describe('FancyCommand', (it, beforeEach, afterEach) => { | ||
let commands = null; | ||
let gunther = null; | ||
|
||
beforeEach(async() => { | ||
commands = new MockPlaygroundCommands(); | ||
await commands.loadCommands(); | ||
|
||
gunther = server.playerManager.getById(0 /* Gunther */); | ||
await gunther.identify(); | ||
// Enable |gunther| to use the command by adding an exception. | ||
commands.access.addException('fancy', gunther); | ||
}); | ||
|
||
afterEach(() => commands.dispose()); | ||
|
||
it('should not allow players to fancy others', async(assert) => { | ||
const russell = server.playerManager.getById(1 /* Gunther */); | ||
await russell.identify(); | ||
|
||
assert.isTrue(await gunther.issueCommand('/fancy 1 cow')); | ||
assert.equal(gunther.messages.length, 1); | ||
assert.includes(gunther.messages[0], 'Only administrators can fancy other players.'); | ||
}); | ||
|
||
it('should allow administrators to fancy others', async(assert) => { | ||
const russell = server.playerManager.getById(1 /* Gunther */); | ||
await russell.identify(); | ||
|
||
gunther.level = Player.LEVEL_ADMINISTRATOR | ||
|
||
assert.isTrue(await gunther.issueCommand('/fancy 1 cow')); | ||
assert.equal(gunther.messages.length, 1); | ||
assert.includes(gunther.messages[0], russell.name + ' is now a cow.'); | ||
}); | ||
}); |