mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Tests
This commit is contained in:
parent
f46e6acd13
commit
00eb69050f
1
app.js
1
app.js
@ -18,6 +18,7 @@ app.use(express.static(__dirname + '/public'));
|
||||
var manager = new Manager(config);
|
||||
manager.load();
|
||||
var mods = new Mods(config);
|
||||
mods.updateMods();
|
||||
|
||||
var serversRoutes = require('./routes/servers')(manager, mods);
|
||||
var modsRoutes = require('./routes/mods')(mods);
|
||||
|
17
lib/mods.js
17
lib/mods.js
@ -13,7 +13,13 @@ var Mods = function (config) {
|
||||
this.mods = [];
|
||||
|
||||
var self = this;
|
||||
this.updateMods();
|
||||
};
|
||||
|
||||
Mods.removeDuplicates = function (mods) {
|
||||
return mods.reduce(function(a,b){
|
||||
if (a.indexOf(b) < 0 ) a.push(b);
|
||||
return a;
|
||||
},[]);
|
||||
};
|
||||
|
||||
Mods.prototype = new events.EventEmitter();
|
||||
@ -66,18 +72,11 @@ Mods.prototype.isPlayWithSixMod = function (modPath, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
Mods.prototype.removeDuplicates = function (mods) {
|
||||
return mods.reduce(function(a,b){
|
||||
if (a.indexOf(b) < 0 ) a.push(b);
|
||||
return a;
|
||||
},[]);
|
||||
};
|
||||
|
||||
Mods.prototype.resolveMods = function (modsToResolve, cb) {
|
||||
var self = this;
|
||||
playwithsix.resolveDependencies(modsToResolve, {lite: this.liteMods}, function (err, mods) {
|
||||
if (!err && mods) {
|
||||
cb(null, self.removeDuplicates(modsToResolve.concat(mods)));
|
||||
cb(null, Mods.removeDuplicates(modsToResolve.concat(mods)));
|
||||
} else {
|
||||
cb(err);
|
||||
}
|
||||
|
@ -4,7 +4,8 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node app.js"
|
||||
"start": "node app.js",
|
||||
"test": "node node_modules/mocha/bin/mocha --recursive"
|
||||
},
|
||||
"dependencies": {
|
||||
"arma-server": "git+https://github.com/Dahlgren/node-arma-server.git",
|
||||
@ -18,5 +19,9 @@
|
||||
"socket.io": "^1.0.4",
|
||||
"userhome": "^1.0.0",
|
||||
"when": "~3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "~2.1.0",
|
||||
"should": "~5.0.0"
|
||||
}
|
||||
}
|
||||
|
22
test/lib/mods.js
Normal file
22
test/lib/mods.js
Normal file
@ -0,0 +1,22 @@
|
||||
var should = require('should');
|
||||
|
||||
var Mods = require('../../lib/mods.js');
|
||||
|
||||
describe('Mods', function() {
|
||||
describe('removeDuplicates()', function() {
|
||||
it('should remove duplicate mods', function() {
|
||||
Mods.removeDuplicates(['mod1', 'mod1']).should.eql(['mod1']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('search()', function() {
|
||||
it('should find mods', function(done) {
|
||||
var mods = new Mods();
|
||||
mods.search('', function (err, mods) {
|
||||
should(err).be.null;
|
||||
mods.should.not.be.empty;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
12
test/lib/server.js
Normal file
12
test/lib/server.js
Normal file
@ -0,0 +1,12 @@
|
||||
var should = require('should');
|
||||
|
||||
var Server = require('../../lib/server.js');
|
||||
|
||||
describe('Server', function() {
|
||||
describe('toJSON()', function() {
|
||||
it('should include title', function() {
|
||||
var server = new Server(null, null, {title: 'test'});
|
||||
server.toJSON().should.have.property('title', 'test');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user