diff --git a/src/background/strategies/nyaa.js b/src/background/strategies/nyaa.js index e78f74b..3772a44 100644 --- a/src/background/strategies/nyaa.js +++ b/src/background/strategies/nyaa.js @@ -22,14 +22,19 @@ module.exports = class Nyaa html = await fetch('https://nyaa.si/' + (this.threadId ? `view/${this.threadId}` : (this.hash ? `?q=${this.hash}` : ''))) } catch(err) { resolve() + return } - if(!html) + if(!html) { resolve() + return + } html = await html.textConverted() const $ = cheerio.load(html) let topicTitle = $('.panel-title').first().text() - if(!topicTitle) + if(!topicTitle) { resolve() + return + } topicTitle = topicTitle.replace(/\t/g, '').replace(/\n/g, '') diff --git a/tests/sphinx.api.test.js b/tests/sphinx.api.test.js index ef7edf5..a763373 100644 --- a/tests/sphinx.api.test.js +++ b/tests/sphinx.api.test.js @@ -35,6 +35,14 @@ describe("big table for check", () => { assert.equal((await sphinx.query(`select data from feed where id = 1`))[0].data, '{"a":1,"b":2,"c":3,"d":6,"e":5}') }) + it("insert object to database", async function() { + const obj = {a: 1, v: 2} + const p = {id: 3, data: obj} + await sphinx.insertValues('feed', p) + assert.equal((await sphinx.query(`select data from feed where id = 3`))[0].data, '{"a":1,"v":2}') + assert.equal(obj, p.data) + }) + it("close", async function() { await sphinx.end() })