lint also tests folder

This commit is contained in:
Alexey Kasyanchuk 2018-06-30 02:03:43 +03:00
parent 8dc7cfecf9
commit c086cd2087
7 changed files with 126 additions and 126 deletions

View File

@ -1,2 +1,2 @@
"d:\Program Files\Git\bin\bash.exe" -c "find src -name '*.js' ! -type d -exec bash -c 'expand -t 4 \"$0\" > /tmp/e && mv /tmp/e \"$0\"' {} \;" "d:\Program Files\Git\bin\bash.exe" -c "find src tests -name '*.js' ! -type d -exec bash -c 'expand -t 4 \"$0\" > /tmp/e && mv /tmp/e \"$0\"' {} \;"
node_modules\.bin\eslint --fix src node_modules\.bin\eslint --fix src tests

View File

@ -437,24 +437,24 @@ export default class Torrent extends Component {
</ToolTip> </ToolTip>
: :
this.state.startingDownloading && !this.state.downloading this.state.startingDownloading && !this.state.downloading
? ?
<ToolTip hint={__('Serching metadata in progress... Click will delete this torrent.')} right={true}> <ToolTip hint={__('Serching metadata in progress... Click will delete this torrent.')} right={true}>
<div className="overlay-loader" onClick={(e) => { <div className="overlay-loader" onClick={(e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
window.torrentSocket.emit('downloadCancel', torrent.hash) window.torrentSocket.emit('downloadCancel', torrent.hash)
}}> }}>
<div className="loader"> <div className="loader">
<div></div> <div></div>
<div></div> <div></div>
<div></div> <div></div>
<div></div> <div></div>
<div></div> <div></div>
<div></div> <div></div>
<div></div> <div></div>
</div>
</div> </div>
</div> </ToolTip>
</ToolTip>
: :
this.state.downloaded this.state.downloaded
? ?

View File

@ -2,26 +2,26 @@ import electron from "electron";
import { Application } from "spectron"; import { Application } from "spectron";
const startApplication = function() { const startApplication = function() {
this.timeout(30000); this.timeout(30000);
this.app = new Application({ this.app = new Application({
path: electron, path: electron,
args: ["."], args: ["."],
startTimeout: 30000, startTimeout: 30000,
waitTimeout: 30000, waitTimeout: 30000,
quitTimeout: 10000 quitTimeout: 10000
}); });
return this.app.start(); return this.app.start();
}; };
const stopApplication = function() { const stopApplication = function() {
this.timeout(30000); this.timeout(30000);
if (this.app && this.app.isRunning()) { if (this.app && this.app.isRunning()) {
return this.app.stop(); return this.app.stop();
} }
return undefined; return undefined;
}; };
export { export {
startApplication, startApplication,
stopApplication stopApplication
}; };

View File

@ -6,34 +6,34 @@ const {pool} = require('../src/background/mysql')
const forBigTable = require('../src/background/forBigTable') const forBigTable = require('../src/background/forBigTable')
describe("big table for check", () => { describe("big table for check", () => {
let sphinx; let sphinx;
it("init", function() { it("init", function() {
sphinx = pool() sphinx = pool()
expect(sphinx) expect(sphinx)
}) })
it("insert 13 records for big table check", async function() { it("insert 13 records for big table check", async function() {
for(let i = 1; i < 14; i++) for(let i = 1; i < 14; i++)
await sphinx.query(`insert into feed(id, data) values(${i}, 'a')`) await sphinx.query(`insert into feed(id, data) values(${i}, 'a')`)
}) })
it("for each 3 records of big table", async function() { it("for each 3 records of big table", async function() {
const records = [] const records = []
await forBigTable(sphinx, 'feed', record => records.push(record), null, 3) await forBigTable(sphinx, 'feed', record => records.push(record), null, 3)
expect(records.length === 13) expect(records.length === 13)
}) })
it("for each 13 records of big table", async function() { it("for each 13 records of big table", async function() {
const records = [] const records = []
await forBigTable(sphinx, 'feed', record => records.push(record), null, 13) await forBigTable(sphinx, 'feed', record => records.push(record), null, 13)
expect(records.length === 13) expect(records.length === 13)
expect(records[1].id === 2) expect(records[1].id === 2)
}) })
it("for each 15 records of big table", async function() { it("for each 15 records of big table", async function() {
const records = [] const records = []
await forBigTable(sphinx, 'feed', record => records.push(record), null, 15) await forBigTable(sphinx, 'feed', record => records.push(record), null, 15)
expect(records.length === 13) expect(records.length === 13)
}) })
}); });

View File

@ -1,13 +1,13 @@
import {startApplication, stopApplication} from "../tests/application"; import {startApplication, stopApplication} from "../tests/application";
describe("application", () => { describe("application", () => {
before(startApplication); before(startApplication);
after(stopApplication); after(stopApplication);
it("check start", async function() { it("check start", async function() {
const { app } = this const { app } = this
await app.client.waitForExist('#index-window') await app.client.waitForExist('#index-window')
}); });
//TESTS //TESTS
}); });

View File

@ -4,58 +4,58 @@ const mysql = require('mysql')
const config = require('../src/background/config') const config = require('../src/background/config')
describe("sphinx", () => { describe("sphinx", () => {
let sphinx; let sphinx;
it("init", function() { it("init", function() {
sphinx = mysql.createPool({ sphinx = mysql.createPool({
connectionLimit: config.sphinx.connectionLimit, connectionLimit: config.sphinx.connectionLimit,
host : config.sphinx.host, host : config.sphinx.host,
port : config.sphinx.port port : config.sphinx.port
}); });
expect(sphinx) expect(sphinx)
}) })
it("insert", function(done) { it("insert", function(done) {
sphinx.query("INSERT INTO files(id, hash, path, pathIndex, size) VALUES(1, 'a', 'bashaa', 'bashaa', 50)", (err) => { sphinx.query("INSERT INTO files(id, hash, path, pathIndex, size) VALUES(1, 'a', 'bashaa', 'bashaa', 50)", (err) => {
if(err) if(err)
throw new Error(err) throw new Error(err)
sphinx.query("INSERT INTO files(id, hash, path, pathIndex, size) VALUES(2, 'b', 'biotu', 'biotu', 30)", (err) => { sphinx.query("INSERT INTO files(id, hash, path, pathIndex, size) VALUES(2, 'b', 'biotu', 'biotu', 30)", (err) => {
if(err) if(err)
throw new Error(err) throw new Error(err)
done() done()
}) })
}) })
}) })
it("select", function(done) { it("select", function(done) {
sphinx.query("select * from files where hash = 'a'", (err, result) => { sphinx.query("select * from files where hash = 'a'", (err, result) => {
if(!result) if(!result)
throw new Error(err) throw new Error(err)
if(result.length !== 1) if(result.length !== 1)
throw new Error('not one result') throw new Error('not one result')
if(result[0].size !== 50) if(result[0].size !== 50)
throw new Error('not 50 in field') throw new Error('not 50 in field')
done() done()
}) })
}) })
it("search", function(done) { it("search", function(done) {
sphinx.query("select * from files where MATCH('bashaa')", (err, result) => { sphinx.query("select * from files where MATCH('bashaa')", (err, result) => {
if(!result) if(!result)
throw new Error(err) throw new Error(err)
if(result.length !== 1) if(result.length !== 1)
throw new Error('not one result') throw new Error('not one result')
if(result[0].hash !== 'a') if(result[0].hash !== 'a')
throw new Error('not a in hash') throw new Error('not a in hash')
if(result[0].size !== 50) if(result[0].size !== 50)
throw new Error('not 50 in field') throw new Error('not 50 in field')
done() done()
}) })
}) })
}); });

View File

@ -4,22 +4,22 @@ const client = new (require('../src/background/bt/client'))
const spider = new (require('../src/background/bt/spider'))(client) const spider = new (require('../src/background/bt/spider'))(client)
describe("spider check", () => { describe("spider check", () => {
it("listen", function() { it("listen", function() {
spider.listen(4445) spider.listen(4445)
}) })
it("enshure hash recive", function(done) { it("enshure hash recive", function(done) {
this.timeout(100000); this.timeout(100000);
spider.once('ensureHash', () => done()) spider.once('ensureHash', () => done())
}) })
it("get metadata", function(done) { it("get metadata", function(done) {
this.timeout(120000); this.timeout(120000);
client.once('complete', function (metadata, infohash, rinfo) { client.once('complete', function (metadata, infohash, rinfo) {
expect(Buffer.isBuffer(infohash)) expect(Buffer.isBuffer(infohash))
expect(infohash.length == 20) expect(infohash.length == 20)
spider.close(() => done()) spider.close(() => done())
}) })
}); });
}); });