From 1fbc889011abd9ec1d965dec30fef89ad3c6c3ae Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Fri, 15 Jun 2018 16:21:41 +0300 Subject: [PATCH] tests(bigtable): test for bigtable script --- tests/bigtableapi.test.js | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/bigtableapi.test.js diff --git a/tests/bigtableapi.test.js b/tests/bigtableapi.test.js new file mode 100644 index 0000000..a84992d --- /dev/null +++ b/tests/bigtableapi.test.js @@ -0,0 +1,49 @@ +const expect = (is) => { + if(!is) + throw new Error('expected not done'); +} +import testUtils from "./utils"; + +const {pool} = require('../src/background/mysql') +const forBigTable = require('../src/background/forBigTable') + +describe("big table for check", () => { + before(testUtils.beforeEach); + after(testUtils.afterEach); + + it("runned", async function() { + const { app } = this + await app.client.waitForExist('#index-window') + }); + + let sphinx; + + it("init", function() { + sphinx = pool() + expect(sphinx) + }) + + it("insert 13 records for big table check", async function() { + for(let i = 1; i < 14; i++) + await sphinx.query(`insert into feed(id, data) values(${i}, 'a')`) + }) + + it("for each 3 records of big table", async function() { + const records = [] + await forBigTable(sphinx, 'feed', record => records.push(record), null, 3) + expect(records.length === 13) + }) + + it("for each 13 records of big table", async function() { + const records = [] + await forBigTable(sphinx, 'feed', record => records.push(record), null, 13) + expect(records.length === 13) + expect(records[1].id === 2) + }) + + it("for each 15 records of big table", async function() { + const records = [] + await forBigTable(sphinx, 'feed', record => records.push(record), null, 15) + expect(records.length === 13) + }) +});