Merge pull request #104 from pdehaan/clean-eslint

Fix a bunch of ESLint and HTMLLint errors
This commit is contained in:
Danny Coates 2017-06-22 10:57:04 -07:00 committed by GitHub
commit da8b4abe41
15 changed files with 677 additions and 1325 deletions

View File

@ -1,13 +1,11 @@
env: env:
browser: true
es6: true es6: true
jquery: true
mocha: true
node: true node: true
extends: extends:
- eslint:recommended - eslint:recommended
- plugin:node/recommended - plugin:node/recommended
- plugin:security/recommended
plugins: plugins:
- node - node
@ -16,18 +14,10 @@ plugins:
root: true root: true
rules: rules:
security/detect-buffer-noassert: warn node/no-unpublished-require: off
security/detect-child-process: warn
security/detect-disable-mustache-escape: warn security/detect-non-literal-fs-filename: off
security/detect-eval-with-expression: warn security/detect-object-injection: off
security/detect-new-buffer: warn
security/detect-no-csrf-before-method-override: warn
security/detect-non-literal-fs-filename: warn
security/detect-non-literal-regexp: warn
security/detect-non-literal-require: warn
security/detect-possible-timing-attacks: warn
security/detect-pseudoRandomBytes: warn
security/detect-unsafe-regex: warn
eqeqeq: error eqeqeq: error
no-console: warn no-console: warn

View File

@ -2,4 +2,5 @@ extends: stylelint-config-standard
rules: rules:
color-hex-case: upper color-hex-case: upper
declaration-colon-newline-after: null
selector-list-comma-newline-after: null selector-list-comma-newline-after: null

View File

@ -9,3 +9,8 @@ deployment:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
- docker build . -t mozilla/portal:latest - docker build . -t mozilla/portal:latest
- docker push mozilla/portal:latest - docker push mozilla/portal:latest
test:
override:
- npm run lint
- npm test

View File

@ -0,0 +1,3 @@
env:
browser: true
jquery: true

View File

@ -1,5 +1,5 @@
const EventEmitter = require('events'); const EventEmitter = require('events');
const { ivToStr, notify } = require('./utils'); const { ivToStr } = require('./utils');
class FileSender extends EventEmitter { class FileSender extends EventEmitter {
constructor(file) { constructor(file) {
@ -23,7 +23,7 @@ class FileSender extends EventEmitter {
} }
if (xhr.status === 200) { if (xhr.status === 200) {
console.log('The file was successfully deleted.') console.log('The file was successfully deleted.');
} else { } else {
console.log('The file has expired, or has already been deleted.'); console.log('The file has expired, or has already been deleted.');
} }

View File

@ -1,5 +1,5 @@
const FileSender = require('./fileSender'); const FileSender = require('./fileSender');
const { notify } = require('./utils') const { notify } = require('./utils');
const $ = require('jquery'); const $ = require('jquery');
$(document).ready(function() { $(document).ready(function() {
@ -15,7 +15,7 @@ $(document).ready(function() {
// copy link to clipboard // copy link to clipboard
$copyBtn.click(() => { $copyBtn.click(() => {
var aux = document.createElement('input'); const aux = document.createElement('input');
aux.setAttribute('value', $('#link').attr('value')); aux.setAttribute('value', $('#link').attr('value'));
document.body.appendChild(aux); document.body.appendChild(aux);
aux.select(); aux.select();
@ -61,7 +61,6 @@ $(document).ready(function() {
const popupDiv = document.createElement('div'); const popupDiv = document.createElement('div');
const $popupText = $('<span>', { class: 'popuptext' }); const $popupText = $('<span>', { class: 'popuptext' });
const cellText = document.createTextNode(file.name); const cellText = document.createTextNode(file.name);
const progress = document.createElement('p');
name.appendChild(cellText); name.appendChild(cellText);

View File

@ -21,15 +21,14 @@ function strToIv(str) {
} }
function notify(str) { function notify(str) {
if (!("Notification" in window)) { if (!('Notification' in window)) {
return; return;
} else if (Notification.permission === 'granted') { } else if (Notification.permission === 'granted') {
new Notification(str) new Notification(str);
} else if (Notification.permission !== 'denied') { } else if (Notification.permission !== 'denied') {
Notification.requestPermission(function(permission) { Notification.requestPermission(function(permission) {
if (permission === 'granted') if (permission === 'granted') new Notification(str);
new Notification(str); });
})
} }
} }

1576
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,24 +17,23 @@
"jquery": "^3.2.1", "jquery": "^3.2.1",
"mozlog": "^2.1.1", "mozlog": "^2.1.1",
"node-fetch": "^1.7.1", "node-fetch": "^1.7.1",
"path": "^0.12.7",
"redis": "^2.7.1" "redis": "^2.7.1"
}, },
"devDependencies": { "devDependencies": {
"browserify": "^14.4.0", "browserify": "^14.4.0",
"buffer-shims": "^1.0.0", "buffer-shims": "^1.0.0",
"cross-env": "^5.0.0", "cross-env": "^5.0.0",
"eslint": "3.19.0", "eslint": "^4.0.0",
"eslint-plugin-node": "5.0.0", "eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-security": "1.3.0", "eslint-plugin-node": "^5.0.0",
"htmllint-cli": "0.0.6", "eslint-plugin-security": "^1.4.0",
"mocha": "^3.4.2", "mocha": "^3.4.2",
"npm-run-all": "4.0.2", "npm-run-all": "^4.0.2",
"prettier": "1.4.4", "prettier": "^1.4.4",
"proxyquire": "^1.8.0", "proxyquire": "^1.8.0",
"sinon": "^2.3.5", "sinon": "^2.3.5",
"stylelint": "7.11.0", "stylelint": "^7.11.0",
"stylelint-config-standard": "16.0.0", "stylelint-config-standard": "^16.0.0",
"watchify": "^3.9.0" "watchify": "^3.9.0"
}, },
"engines": { "engines": {
@ -44,10 +43,9 @@
"repository": "mozilla/something-awesome", "repository": "mozilla/something-awesome",
"scripts": { "scripts": {
"dev": "watchify frontend/src/main.js -o public/bundle.js -d | node server/portal_server.js", "dev": "watchify frontend/src/main.js -o public/bundle.js -d | node server/portal_server.js",
"format": "prettier 'frontend/src/*.js' 'server/*.js' 'public/*.css' --single-quote --write", "format": "prettier 'frontend/src/*.js' 'public/*.css' 'server/*.js' 'test/*.js' --single-quote --write",
"lint": "npm-run-all lint:*", "lint": "npm-run-all lint:*",
"lint:css": "stylelint 'public/*.css'", "lint:css": "stylelint 'public/*.css'",
"lint:html": "htmllint 'views/*.handlebars'",
"lint:js": "eslint .", "lint:js": "eslint .",
"start": "browserify frontend/src/main.js -o public/bundle.js -d | cross-env NODE_ENV=production node server/portal_server.js", "start": "browserify frontend/src/main.js -o public/bundle.js -d | cross-env NODE_ENV=production node server/portal_server.js",
"test": "mocha" "test": "mocha"

View File

@ -16,10 +16,13 @@ const log = mozlog('portal.server');
const app = express(); const app = express();
app.engine('handlebars', exphbs({ app.engine(
defaultLayout: 'main', 'handlebars',
partialsDir: 'views/partials/' exphbs({
})); defaultLayout: 'main',
partialsDir: 'views/partials/'
})
);
app.set('view engine', 'handlebars'); app.set('view engine', 'handlebars');
app.use(helmet()); app.use(helmet());

21
test/.eslintrc.yml Normal file
View File

@ -0,0 +1,21 @@
env:
mocha: true
extends:
- plugin:mocha/recommended
plugins:
- mocha
- node
rules:
node/no-unpublished-require: off
mocha/handle-done-callback: error
mocha/no-exclusive-tests: error
mocha/no-identical-title: warn
mocha/no-mocha-arrows: error
mocha/no-nested-tests: error
mocha/no-pending-tests: error
mocha/no-return-and-callback: warn
mocha/no-skipped-tests: error

View File

@ -6,12 +6,12 @@ const crypto = require('crypto');
const conf = require('../server/config.js'); const conf = require('../server/config.js');
conf.notLocalHost = true; conf.notLocalHost = true;
let redisStub = {}; const redisStub = {};
let exists = sinon.stub(); const exists = sinon.stub();
let hget = sinon.stub(); const hget = sinon.stub();
let hmset = sinon.stub(); const hmset = sinon.stub();
let expire = sinon.spy(); const expire = sinon.spy();
let del = sinon.stub(); const del = sinon.stub();
redisStub.createClient = function() { redisStub.createClient = function() {
return { return {
@ -21,145 +21,156 @@ redisStub.createClient = function() {
hmset: hmset, hmset: hmset,
expire: expire, expire: expire,
del: del del: del
} };
} };
let fsStub = {}; const fsStub = {};
fsStub.statSync = sinon.stub(); fsStub.statSync = sinon.stub();
fsStub.createReadStream = sinon.stub(); fsStub.createReadStream = sinon.stub();
fsStub.createWriteStream = sinon.stub(); fsStub.createWriteStream = sinon.stub();
fsStub.unlinkSync = sinon.stub(); fsStub.unlinkSync = sinon.stub();
let logStub = {}; const logStub = {};
logStub.info = sinon.stub(); logStub.info = sinon.stub();
logStub.error = sinon.stub(); logStub.error = sinon.stub();
let s3Stub = {}; const s3Stub = {};
s3Stub.headObject = sinon.stub(); s3Stub.headObject = sinon.stub();
s3Stub.getObject = sinon.stub(); s3Stub.getObject = sinon.stub();
s3Stub.upload = sinon.stub(); s3Stub.upload = sinon.stub();
s3Stub.deleteObject = sinon.stub(); s3Stub.deleteObject = sinon.stub();
let awsStub = { const awsStub = {
S3: function() { S3: function() {
return s3Stub; return s3Stub;
} }
} };
const storage = proxyquire('../server/storage', { const storage = proxyquire('../server/storage', {
'redis': redisStub, redis: redisStub,
'fs': fsStub, fs: fsStub,
'./log.js': function() { return logStub }, './log.js': function() {
return logStub;
},
'aws-sdk': awsStub 'aws-sdk': awsStub
}); });
describe('Testing Length using aws', function() { describe('Testing Length using aws', function() {
it('Filesize returns properly if id exists', function() { it('Filesize returns properly if id exists', function() {
s3Stub.headObject.callsArgWith(1, null, {ContentLength: 1}); s3Stub.headObject.callsArgWith(1, null, { ContentLength: 1 });
return storage.length('123') return storage
.then(reply => assert.equal(reply, 1)) .length('123')
.catch(err => assert.fail()) .then(reply => assert.equal(reply, 1))
}) .catch(err => assert.fail());
});
it('Filesize fails if the id does not exist', function() { it('Filesize fails if the id does not exist', function() {
s3Stub.headObject.callsArgWith(1, new Error(), null); s3Stub.headObject.callsArgWith(1, new Error(), null);
return storage.length('123') return storage
.then(reply => assert.fail()) .length('123')
.catch(err => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
});
}); });
describe('Testing Get using aws', function() { describe('Testing Get using aws', function() {
it('Should not error out when the file exists', function() { it('Should not error out when the file exists', function() {
let spy = sinon.spy(); const spy = sinon.spy();
s3Stub.getObject.returns({ s3Stub.getObject.returns({
createReadStream: spy createReadStream: spy
}); });
storage.get('123'); storage.get('123');
assert(spy.calledOnce); assert(spy.calledOnce);
}) });
it('Should error when the file does not exist', function() { it('Should error when the file does not exist', function() {
let err = function() { throw new Error(); } const err = function() {
let spy = sinon.spy(err); throw new Error();
};
const spy = sinon.spy(err);
s3Stub.getObject.returns({ s3Stub.getObject.returns({
createReadStream: spy createReadStream: spy
}); });
assert.equal(storage.get('123'), null); assert.equal(storage.get('123'), null);
assert(spy.threw()); assert(spy.threw());
}) });
}); });
describe('Testing Set using aws', function() { describe('Testing Set using aws', function() {
beforeEach(function() { beforeEach(function() {
expire.reset(); expire.reset();
}) });
after(function() { after(function() {
crypto.randomBytes.restore(); crypto.randomBytes.restore();
}) });
it('Should pass when the file is successfully uploaded and no bitly key', function() { it('Should pass when the file is successfully uploaded and no bitly key', function() {
conf.bitly_key = null; conf.bitly_key = null;
const buf = new Buffer(10); const buf = Buffer.alloc(10);
sinon.stub(crypto, 'randomBytes').returns(buf); sinon.stub(crypto, 'randomBytes').returns(buf);
s3Stub.upload.callsArgWith(1, null, {}); s3Stub.upload.callsArgWith(1, null, {});
return storage.set('123', {}, 'Filename.moz', 'url.com') return storage
.then(reply => { .set('123', {}, 'Filename.moz', 'url.com')
assert.equal(reply.uuid, buf.toString('hex')); .then(reply => {
assert.equal(reply.url, 'url.com'); assert.equal(reply.uuid, buf.toString('hex'));
assert.notEqual(reply.uuid, null); assert.equal(reply.url, 'url.com');
assert(expire.calledOnce); assert.notEqual(reply.uuid, null);
assert(expire.calledWith('123', 86400000)); assert(expire.calledOnce);
}) assert(expire.calledWith('123', 86400000));
.catch(err => assert.fail()); })
}) .catch(err => assert.fail());
});
it('Should fail if there was an error during uploading', function() { it('Should fail if there was an error during uploading', function() {
s3Stub.upload.callsArgWith(1, new Error(), null); s3Stub.upload.callsArgWith(1, new Error(), null);
return storage.set('123', {}, 'Filename.moz', 'url.com') return storage
.then(reply => assert.fail()) .set('123', {}, 'Filename.moz', 'url.com')
.catch(err => assert(1)); .then(_reply => assert.fail())
}) .catch(err => assert(1));
});
}); });
describe('Testing Delete from aws', function() { describe('Testing Delete from aws', function() {
it('Returns successfully if the id is deleted off aws', function() { it('Returns successfully if the id is deleted off aws', function() {
hget.callsArgWith(2, null, 'delete_token'); hget.callsArgWith(2, null, 'delete_token');
s3Stub.deleteObject.callsArgWith(1, null, {}); s3Stub.deleteObject.callsArgWith(1, null, {});
return storage.delete('file_id', 'delete_token') return storage
.then(reply => assert(1), err => assert.fail()) .delete('file_id', 'delete_token')
}) .then(_reply => assert(1), err => assert.fail());
});
it('Delete fails if id exists locally but does not in aws', function() { it('Delete fails if id exists locally but does not in aws', function() {
hget.callsArgWith(2, null, 'delete_token'); hget.callsArgWith(2, null, 'delete_token');
s3Stub.deleteObject.callsArgWith(1, new Error(), {}); s3Stub.deleteObject.callsArgWith(1, new Error(), {});
return storage.delete('file_id', 'delete_token') return storage
.then(reply => assert.fail(), err => assert(1)) .delete('file_id', 'delete_token')
}) .then(_reply => assert.fail(), err => assert(1));
});
it('Delete fails if the delete token does not match', function() { it('Delete fails if the delete token does not match', function() {
hget.callsArgWith(2, null, {}); hget.callsArgWith(2, null, {});
return storage.delete('Filename.moz', 'delete_token') return storage
.then(reply => assert.fail()) .delete('Filename.moz', 'delete_token')
.catch(reply => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
});
}); });
describe('Testing Forced Delete from aws', function() { describe('Testing Forced Delete from aws', function() {
it('Deletes properly if id exists', function() { it('Deletes properly if id exists', function() {
s3Stub.deleteObject.callsArgWith(1, null, {}); s3Stub.deleteObject.callsArgWith(1, null, {});
return storage.forceDelete('file_id', 'delete_token') return storage
.then(reply => assert(1), err => assert.fail()); .forceDelete('file_id', 'delete_token')
}) .then(_reply => assert(1), err => assert.fail());
});
it('Deletes fails if id does not exist', function() { it('Deletes fails if id does not exist', function() {
s3Stub.deleteObject.callsArgWith(1, new Error(), {}); s3Stub.deleteObject.callsArgWith(1, new Error(), {});
return storage.forceDelete('file_id') return storage
.then(reply => assert.fail(), err => assert(1)) .forceDelete('file_id')
}) .then(_reply => assert.fail(), err => assert(1));
});
}) });

View File

@ -2,15 +2,15 @@ const assert = require('assert');
const sinon = require('sinon'); const sinon = require('sinon');
const proxyquire = require('proxyquire'); const proxyquire = require('proxyquire');
const conf = require('../server/config.js') const conf = require('../server/config.js');
conf.notLocalHost = false; conf.notLocalHost = false;
let redisStub = {}; const redisStub = {};
let exists = sinon.stub(); const exists = sinon.stub();
let hget = sinon.stub(); const hget = sinon.stub();
let hmset = sinon.stub(); const hmset = sinon.stub();
let expire = sinon.stub(); const expire = sinon.stub();
let del = sinon.stub(); const del = sinon.stub();
redisStub.createClient = function() { redisStub.createClient = function() {
return { return {
@ -20,80 +20,84 @@ redisStub.createClient = function() {
hmset: hmset, hmset: hmset,
expire: expire, expire: expire,
del: del del: del
} };
} };
let fsStub = {}; const fsStub = {};
fsStub.statSync = sinon.stub(); fsStub.statSync = sinon.stub();
fsStub.createReadStream = sinon.stub(); fsStub.createReadStream = sinon.stub();
fsStub.createWriteStream = sinon.stub(); fsStub.createWriteStream = sinon.stub();
fsStub.unlinkSync = sinon.stub(); fsStub.unlinkSync = sinon.stub();
let logStub = {}; const logStub = {};
logStub.info = sinon.stub(); logStub.info = sinon.stub();
logStub.error = sinon.stub(); logStub.error = sinon.stub();
const storage = proxyquire('../server/storage', { const storage = proxyquire('../server/storage', {
'redis': redisStub, redis: redisStub,
'fs': fsStub, fs: fsStub,
'./log.js': function() { return logStub } './log.js': function() {
return logStub;
}
}); });
describe('Testing Exists from local filesystem', function() { describe('Testing Exists from local filesystem', function() {
it('Exists returns true when file exists', function() { it('Exists returns true when file exists', function() {
exists.callsArgWith(1, null, 1); exists.callsArgWith(1, null, 1);
return storage.exists('test') return storage.exists('test').then(reply => assert(reply));
.then((reply) => assert(reply)); });
})
it('Exists returns false when file does not exist', function() { it('Exists returns false when file does not exist', function() {
exists.callsArgWith(1, null, 0); exists.callsArgWith(1, null, 0);
return storage.exists('test') return storage.exists('test').then(reply => assert(!reply));
.then((reply) => assert(!reply)); });
})
}); });
describe('Testing Filename from local filesystem', function() { describe('Testing Filename from local filesystem', function() {
it('Filename returns properly if id exists', function() { it('Filename returns properly if id exists', function() {
hget.callsArgWith(2, null, 'Filename.moz'); hget.callsArgWith(2, null, 'Filename.moz');
return storage.filename('test') return storage
.then(reply => assert(1)) .filename('test')
.catch(reply => assert.fail()) .then(_reply => assert(1))
}) .catch(err => assert.fail());
});
it('Filename fails if id does not exist', function() { it('Filename fails if id does not exist', function() {
hget.callsArgWith(2, null, 'Filename.moz'); hget.callsArgWith(2, null, 'Filename.moz');
return storage.filename('test') return storage
.then(reply => assert.fail()) .filename('test')
.catch(reply => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
}) });
});
describe('Testing Length from local filesystem', function() { describe('Testing Length from local filesystem', function() {
it('Filesize returns properly if id exists', function() { it('Filesize returns properly if id exists', function() {
fsStub.statSync.returns({size: 10}); fsStub.statSync.returns({ size: 10 });
return storage.length('Filename.moz') return storage
.then(reply => assert(1)) .length('Filename.moz')
.catch(reply => assert.fail()) .then(_reply => assert(1))
}) .catch(err => assert.fail());
});
it('Filesize fails if the id does not exist', function() { it('Filesize fails if the id does not exist', function() {
fsStub.statSync.returns(null); fsStub.statSync.returns(null);
return storage.length('Filename.moz') return storage
.then(reply => assert.fail()) .length('Filename.moz')
.catch(reply => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
}) });
});
describe('Testing Get from local filesystem', function() { describe('Testing Get from local filesystem', function() {
it('Get returns properly if id exists', function() { it('Get returns properly if id exists', function() {
fsStub.createReadStream.returns(1); fsStub.createReadStream.returns(1);
if (storage.get('Filename.moz')) { if (storage.get('Filename.moz')) {
assert(1) assert(1);
} else { } else {
assert.fail(); assert.fail();
} }
}) });
it('Get fails if the id does not exist', function() { it('Get fails if the id does not exist', function() {
fsStub.createReadStream.returns(null); fsStub.createReadStream.returns(null);
@ -102,71 +106,73 @@ describe('Testing Get from local filesystem', function() {
} else { } else {
assert(1); assert(1);
} }
}) });
}) });
describe('Testing Set to local filesystem', function() { describe('Testing Set to local filesystem', function() {
it('Successfully writes the file to the local filesystem', function() { it('Successfully writes the file to the local filesystem', function() {
let stub = sinon.stub(); const stub = sinon.stub();
stub.withArgs('close', sinon.match.any).callsArgWithAsync(1) stub.withArgs('close', sinon.match.any).callsArgWithAsync(1);
stub.withArgs('error', sinon.match.any).returns(1); stub.withArgs('error', sinon.match.any).returns(1);
fsStub.createWriteStream.returns({ on: stub }) fsStub.createWriteStream.returns({ on: stub });
return storage.set('test', { pipe: sinon.stub() }, 'Filename.moz', 'moz.la') return storage
.then(reply => { .set('test', { pipe: sinon.stub() }, 'Filename.moz', 'moz.la')
assert(reply.uuid); .then(reply => {
assert.equal(reply.url, 'moz.la'); assert(reply.uuid);
}) assert.equal(reply.url, 'moz.la');
.catch(reply => assert.fail()) })
}) .catch(err => assert.fail());
});
it('Fails when the file is not properly written to the local filesystem', function() { it('Fails when the file is not properly written to the local filesystem', function() {
let stub = sinon.stub(); const stub = sinon.stub();
stub.withArgs('error', sinon.match.any).callsArgWithAsync(1) stub.withArgs('error', sinon.match.any).callsArgWithAsync(1);
stub.withArgs('close', sinon.match.any).returns(1); stub.withArgs('close', sinon.match.any).returns(1);
fsStub.createWriteStream.returns({ on: stub }) fsStub.createWriteStream.returns({ on: stub });
return storage.set('test', {pipe: sinon.stub()}, 'Filename.moz', 'moz.la') return storage
.then(reply => assert.fail()) .set('test', { pipe: sinon.stub() }, 'Filename.moz', 'moz.la')
.catch(reply => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
}) });
});
describe('Testing Delete from local filesystem', function() { describe('Testing Delete from local filesystem', function() {
it('Deletes properly if id exists', function() { it('Deletes properly if id exists', function() {
hget.callsArgWith(2, null, '123'); hget.callsArgWith(2, null, '123');
fsStub.unlinkSync.returns(1); fsStub.unlinkSync.returns(1);
return storage.delete('Filename.moz', '123') return storage
.then(reply => assert(reply)) .delete('Filename.moz', '123')
.catch(reply => assert.fail()) .then(reply => assert(reply))
}) .catch(err => assert.fail());
});
it('Delete fails if id does not exist', function() { it('Delete fails if id does not exist', function() {
hget.callsArgWith(2, null, null); hget.callsArgWith(2, null, null);
return storage.delete('Filename.moz', '123') return storage
.then(reply => assert.fail()) .delete('Filename.moz', '123')
.catch(reply => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
});
it('Delete fails if the delete token does not match', function() { it('Delete fails if the delete token does not match', function() {
hget.callsArgWith(2, null, null); hget.callsArgWith(2, null, null);
return storage.delete('Filename.moz', '123') return storage
.then(reply => assert.fail()) .delete('Filename.moz', '123')
.catch(reply => assert(1)) .then(_reply => assert.fail())
}) .catch(err => assert(1));
}) });
});
describe('Testing Forced Delete from local filesystem', function() { describe('Testing Forced Delete from local filesystem', function() {
it('Deletes properly if id exists', function() { it('Deletes properly if id exists', function() {
fsStub.unlinkSync.returns(1); fsStub.unlinkSync.returns(1);
return storage.forceDelete('Filename.moz') return storage.forceDelete('Filename.moz').then(reply => assert(reply));
.then(reply => assert(reply)) });
})
it('Deletes fails if id does not exist, but no reject is called', function() { it('Deletes fails if id does not exist, but no reject is called', function() {
fsStub.unlinkSync.returns(0); fsStub.unlinkSync.returns(0);
return storage.forceDelete('Filename.moz') return storage.forceDelete('Filename.moz').then(reply => assert(!reply));
.then(reply => assert(!reply)) });
}) });
})

View File

@ -3,7 +3,7 @@
<head> <head>
<title>Download your file</title> <title>Download your file</title>
<script src="/bundle.js"></script> <script src="/bundle.js"></script>
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css"> <link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css" />
<link rel="stylesheet" type="text/css" href="/main.css" /> <link rel="stylesheet" type="text/css" href="/main.css" />
{{#if shouldRenderAnalytics}} {{#if shouldRenderAnalytics}}
{{> analytics trackerId=trackerId}} {{> analytics trackerId=trackerId}}
@ -48,11 +48,9 @@
<div class="share-window"> <div class="share-window">
<img src="/resources/link_expired.png" alt="Link expired" /> <img src="/resources/link_expired.png" alt="Link expired" />
</div> </div>
<!-- htmllint id-no-dup="false" -->
<div class="send-new" id="send-file"> <div class="send-new" id="send-file">
Send your own files Send your own files
</div> </div>
<!-- htmllint tag-bans="$previous" -->
{{/if}} {{/if}}
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@
<head> <head>
<title>Firefox Fileshare</title> <title>Firefox Fileshare</title>
<script src="/bundle.js"></script> <script src="/bundle.js"></script>
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css"> <link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css" />
<link rel="stylesheet" type="text/css" href="/main.css" /> <link rel="stylesheet" type="text/css" href="/main.css" />
{{#if shouldRenderAnalytics}} {{#if shouldRenderAnalytics}}
{{> analytics trackerId=trackerId}} {{> analytics trackerId=trackerId}}
@ -38,12 +38,10 @@
<div id="file-list"> <div id="file-list">
<table id="uploaded-files"> <table id="uploaded-files">
<tr> <tr>
<!-- htmllint attr-bans="false" -->
<th width="30%">File</th> <th width="30%">File</th>
<th width="45%">Copy URL</th> <th width="45%">Copy URL</th>
<th width="18%">Expires in</th> <th width="18%">Expires in</th>
<th width="7%">Delete</th> <th width="7%">Delete</th>
<!-- htmllint tag-bans="$previous" -->
</tr> </tr>
</table> </table>
</div> </div>