Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a skeleton for the RadioManager object
- Loading branch information
1 parent
d43a6ba
commit 0f3a741
Showing
4 changed files
with
66 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2017 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. | ||
|
||
// | ||
class RadioManager { | ||
constructor(selection, settings) { | ||
this.selection_ = selection; | ||
this.settings_ = settings; | ||
} | ||
|
||
// Returns whether the radio feature should be enabled at all. | ||
isEnabled() { return this.settings_().getValue('radio/enabled'); } | ||
|
||
dispose() {} | ||
} | ||
|
||
exports = RadioManager; |
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 2017 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. | ||
|
||
const ChannelSelection = require('features/radio/channel_selection.js'); | ||
const MockAnnounce = require('features/announce/test/mock_announce.js'); | ||
const RadioManager = require('features/radio/radio_manager.js'); | ||
|
||
describe('RadioManager', (it, beforeEach, afterEach) => { | ||
let manager = null; | ||
let settings = null; | ||
|
||
beforeEach(() => { | ||
settings = server.featureManager.loadFeature('settings'); | ||
|
||
const announce = new MockAnnounce(); | ||
const selection = new ChannelSelection(() => announce, () => settings); | ||
selection.loadConfigurationFromArray([ | ||
{ | ||
name: "LVP Radio", | ||
stream: "https://play.sa-mp.nl/stream.pls" | ||
} | ||
]); | ||
|
||
manager = new RadioManager(selection, () => settings); | ||
}); | ||
|
||
afterEach(() => { | ||
manager.selection_.dispose(); | ||
manager.dispose(); | ||
}); | ||
|
||
it('should keep track of whether the feature is enabled', assert => { | ||
assert.isTrue(settings.getValue('radio/enabled')); | ||
assert.isTrue(manager.isEnabled()); | ||
|
||
settings.setValue('radio/enabled', false); | ||
|
||
assert.isFalse(settings.getValue('radio/enabled')); | ||
assert.isFalse(manager.isEnabled()); | ||
}); | ||
}); |