mirror of
https://github.com/SunRed/haste-server.git
synced 2025-09-04 04:50:14 +02:00
Updated eslint rules
This commit is contained in:
parent
4a583a52ce
commit
e4eeec3d27
19 changed files with 1096 additions and 550 deletions
|
@ -5,22 +5,22 @@ const assert = require('assert');
|
|||
const DocumentHandler = require('../lib/document_handler');
|
||||
const Generator = require('../lib/key_generators/random');
|
||||
|
||||
describe('document_handler', function() {
|
||||
describe('document_handler', function(){
|
||||
|
||||
describe('randomKey', function() {
|
||||
describe('randomKey', function(){
|
||||
|
||||
it('should choose a key of the proper length', function() {
|
||||
let gen = new Generator();
|
||||
let dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen });
|
||||
assert.equal(6, dh.acceptableKey().length);
|
||||
});
|
||||
it('should choose a key of the proper length', function(){
|
||||
let gen = new Generator();
|
||||
let dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen });
|
||||
assert.equal(6, dh.acceptableKey().length);
|
||||
});
|
||||
|
||||
it('should choose a default key length', function() {
|
||||
let gen = new Generator();
|
||||
let dh = new DocumentHandler({ keyGenerator: gen });
|
||||
assert.equal(dh.keyLength, DocumentHandler.defaultKeyLength);
|
||||
});
|
||||
it('should choose a default key length', function(){
|
||||
let gen = new Generator();
|
||||
let dh = new DocumentHandler({ keyGenerator: gen });
|
||||
assert.equal(dh.keyLength, DocumentHandler.defaultKeyLength);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -6,28 +6,28 @@ const fs = require('fs');
|
|||
|
||||
const Generator = require('../../lib/key_generators/dictionary');
|
||||
|
||||
describe('RandomKeyGenerator', function() {
|
||||
describe('randomKey', function() {
|
||||
it('should throw an error if given no options', () => {
|
||||
assert.throws(() => {
|
||||
new Generator();
|
||||
}, Error);
|
||||
});
|
||||
describe('RandomKeyGenerator', function(){
|
||||
describe('randomKey', function(){
|
||||
it('should throw an error if given no options', () => {
|
||||
assert.throws(() => {
|
||||
new Generator();
|
||||
}, Error);
|
||||
});
|
||||
|
||||
it('should throw an error if given no path', () => {
|
||||
assert.throws(() => {
|
||||
new Generator({});
|
||||
}, Error);
|
||||
});
|
||||
it('should throw an error if given no path', () => {
|
||||
assert.throws(() => {
|
||||
new Generator({});
|
||||
}, Error);
|
||||
});
|
||||
|
||||
it('should return a key of the proper number of words from the given dictionary', () => {
|
||||
const path = '/tmp/haste-server-test-dictionary';
|
||||
const words = ['cat'];
|
||||
fs.writeFileSync(path, words.join('\n'));
|
||||
it('should return a key of the proper number of words from the given dictionary', () => {
|
||||
const path = '/tmp/haste-server-test-dictionary';
|
||||
const words = ['cat'];
|
||||
fs.writeFileSync(path, words.join('\n'));
|
||||
|
||||
const gen = new Generator({path}, () => {
|
||||
assert.equal('catcatcat', gen.createKey(3));
|
||||
});
|
||||
});
|
||||
});
|
||||
const gen = new Generator({path}, () => {
|
||||
assert.equal('catcatcat', gen.createKey(3));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,48 +7,48 @@ winston.remove(winston.transports.Console);
|
|||
|
||||
const RedisDocumentStore = require('../lib/document_stores/redis');
|
||||
|
||||
describe('redis_document_store', function() {
|
||||
describe('redis_document_store', function(){
|
||||
|
||||
/* reconnect to redis on each test */
|
||||
afterEach(function() {
|
||||
if (RedisDocumentStore.client) {
|
||||
RedisDocumentStore.client.quit();
|
||||
RedisDocumentStore.client = false;
|
||||
}
|
||||
});
|
||||
/* reconnect to redis on each test */
|
||||
afterEach(function(){
|
||||
if (RedisDocumentStore.client){
|
||||
RedisDocumentStore.client.quit();
|
||||
RedisDocumentStore.client = false;
|
||||
}
|
||||
});
|
||||
|
||||
describe('set', function() {
|
||||
describe('set', function(){
|
||||
|
||||
it('should be able to set a key and have an expiration set', function(done) {
|
||||
let store = new RedisDocumentStore({ expire: 10 });
|
||||
store.set('hello1', 'world', function() {
|
||||
RedisDocumentStore.client.ttl('hello1', function(err, res) {
|
||||
assert.ok(res > 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should be able to set a key and have an expiration set', function(done){
|
||||
let store = new RedisDocumentStore({ expire: 10 });
|
||||
store.set('hello1', 'world', function(){
|
||||
RedisDocumentStore.client.ttl('hello1', function(err, res){
|
||||
assert.ok(res > 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not set an expiration when told not to', function(done) {
|
||||
let store = new RedisDocumentStore({ expire: 10 });
|
||||
store.set('hello2', 'world', function() {
|
||||
RedisDocumentStore.client.ttl('hello2', function(err, res) {
|
||||
assert.equal(-1, res);
|
||||
done();
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
it('should not set an expiration when told not to', function(done){
|
||||
let store = new RedisDocumentStore({ expire: 10 });
|
||||
store.set('hello2', 'world', function(){
|
||||
RedisDocumentStore.client.ttl('hello2', function(err, res){
|
||||
assert.equal(-1, res);
|
||||
done();
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
|
||||
it('should not set an expiration when expiration is off', function(done) {
|
||||
let store = new RedisDocumentStore({ expire: false });
|
||||
store.set('hello3', 'world', function() {
|
||||
RedisDocumentStore.client.ttl('hello3', function(err, res) {
|
||||
assert.equal(-1, res);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should not set an expiration when expiration is off', function(done){
|
||||
let store = new RedisDocumentStore({ expire: false });
|
||||
store.set('hello3', 'world', function(){
|
||||
RedisDocumentStore.client.ttl('hello3', function(err, res){
|
||||
assert.equal(-1, res);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue