TestScripts 1
- added circleci configuration - added mockobjects for testing without the discord api - added a testscript for the music librarypull/21/head
parent
0729c9b31c
commit
bcfbada46c
@ -0,0 +1,41 @@
|
||||
# Javascript Node CircleCI 2.0 configuration file
|
||||
#
|
||||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
||||
#
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
# specify the version you desire here
|
||||
- image: circleci/node:7.10
|
||||
|
||||
# Specify service dependencies here if necessary
|
||||
# CircleCI maintains a library of pre-built images
|
||||
# documented at https://circleci.com/docs/2.0/circleci-images/
|
||||
# - image: circleci/mongo:3.4.4
|
||||
|
||||
working_directory: ~/repo
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "package.json" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
|
||||
- run:
|
||||
name: Installing dependencies
|
||||
command: npm install
|
||||
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v1-dependencies-{{ checksum "package.json" }}
|
||||
|
||||
# run tests!
|
||||
- run:
|
||||
name: Testing ./lib/music
|
||||
command: node ./test/musicTest.js
|
@ -0,0 +1,38 @@
|
||||
exports.mockDispatcher = {
|
||||
pause: () => console.log('pause();'),
|
||||
resume: () => console.log('resume();'),
|
||||
setVolume: (perc) => console.log(`setVolume(${perc});`),
|
||||
on: (event, callback) => console.log(`on(${event}, ${callback});`),
|
||||
end: () => console.log('end();')
|
||||
};
|
||||
|
||||
exports.mockConnection = {
|
||||
channel: {
|
||||
members: {
|
||||
size: 10
|
||||
},
|
||||
leave: () => console.log('leave();')
|
||||
},
|
||||
status: 0,
|
||||
playFile: (fname) => {
|
||||
console.log(`playFile(${fname});`);
|
||||
return exports.mockDispatcher;
|
||||
},
|
||||
playStream: (stream, opts) => {
|
||||
console.log(`playStream(ytdl, ${opts};`);
|
||||
return exports.mockDispatcher;
|
||||
},
|
||||
disconnect: () => console.log('disconnect();')
|
||||
};
|
||||
|
||||
exports.mockVoicechannel = {
|
||||
name: 'mockVoicechannel',
|
||||
join: () => {
|
||||
console.log('join();');
|
||||
return new Promise((rs, rj) => rs(exports.mockConnection));
|
||||
},
|
||||
members: {
|
||||
size: 10
|
||||
},
|
||||
leave: () => console.log('leave();')
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
const music = require('../lib/music.js'),
|
||||
mockclasses = require('./mockobjects.js');
|
||||
|
||||
function main() {
|
||||
let dj = new music.DJ(mockclasses.mockVoicechannel)
|
||||
music.setLogger({
|
||||
error: () => {},
|
||||
warn: () => {},
|
||||
info: () => {},
|
||||
verbose: () => {},
|
||||
debug: () => {}
|
||||
});
|
||||
dj.connect().then(() => {
|
||||
console.log('connected', dj.connected);
|
||||
dj.playFile('test');
|
||||
dj.playYouTube('https://www.youtube.com/watch?v=TEST');
|
||||
dj.setVolume(1);
|
||||
dj.pause();
|
||||
dj.resume();
|
||||
dj.skip();
|
||||
dj.stop();
|
||||
dj.shuffle();
|
||||
console.log(dj.playlist);
|
||||
console.log(dj.song);
|
||||
dj.clear();
|
||||
});
|
||||
}
|
||||
|
||||
// Executing the main function
|
||||
if (typeof require !== 'undefined' && require.main === module) {
|
||||
main();
|
||||
}
|
Loading…
Reference in New Issue