|
| 1 | +// Copyright 2020 Las Venturas Playground. All rights reserved. |
| 2 | +// Use of this source code is governed by the MIT license, a copy of which can |
| 3 | +// be found in the LICENSE file. |
| 4 | + |
| 5 | +import MockPlaygroundCommands from 'features/playground/test/mock_playground_commands.js'; |
| 6 | + |
| 7 | +describe('FancyCommand', (it, beforeEach, afterEach) => { |
| 8 | + let commands = null; |
| 9 | + let gunther = null; |
| 10 | + |
| 11 | + beforeEach(async() => { |
| 12 | + commands = new MockPlaygroundCommands(); |
| 13 | + await commands.loadCommands(); |
| 14 | + |
| 15 | + gunther = server.playerManager.getById(0 /* Gunther */); |
| 16 | + await gunther.identify(); |
| 17 | + // Enable |gunther| to use the command by adding an exception. |
| 18 | + commands.access.addException('fancy', gunther); |
| 19 | + }); |
| 20 | + |
| 21 | + afterEach(() => commands.dispose()); |
| 22 | + |
| 23 | + it('should not allow players to fancy others', async(assert) => { |
| 24 | + const russell = server.playerManager.getById(1 /* Gunther */); |
| 25 | + await russell.identify(); |
| 26 | + |
| 27 | + assert.isTrue(await gunther.issueCommand('/fancy 1 cow')); |
| 28 | + assert.equal(gunther.messages.length, 1); |
| 29 | + assert.includes(gunther.messages[0], 'Only administrators can fancy other players.'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should allow administrators to fancy others', async(assert) => { |
| 33 | + const russell = server.playerManager.getById(1 /* Gunther */); |
| 34 | + await russell.identify(); |
| 35 | + |
| 36 | + gunther.level = Player.LEVEL_ADMINISTRATOR |
| 37 | + |
| 38 | + assert.isTrue(await gunther.issueCommand('/fancy 1 cow')); |
| 39 | + assert.equal(gunther.messages.length, 1); |
| 40 | + assert.includes(gunther.messages[0], russell.name + ' is now a cow.'); |
| 41 | + }); |
| 42 | +}); |
0 commit comments