diff --git a/test/test_amazon.js b/test/test_amazon.js index 496d5b7..aa38e82 100644 --- a/test/test_amazon.js +++ b/test/test_amazon.js @@ -1,5 +1,6 @@ +'use strict'; const se_scraper = require('./../index.js'); -var assert = require('chai').assert; +const assert = require('chai').assert; /* * Use chai and mocha for tests. @@ -113,7 +114,6 @@ async function no_results_test() { function test_case_no_results(response) { assert.equal(response.metadata.num_requests, 1); - results = response.results; for (let query in response.results) { assert.containsAllKeys(response.results, keywords_no_results, 'not all keywords were scraped.'); @@ -134,7 +134,8 @@ function test_case_no_results(response) { } } -(async () => { - await normal_search_test(); - await no_results_test(); -})(); \ No newline at end of file +describe('Amazon', function(){ + this.timeout(30000); + it('normal search test', normal_search_test); + it('no results test', no_results_test); +}); \ No newline at end of file diff --git a/test/test_baidu.js b/test/test_baidu.js index 3e9cba2..887d7d1 100644 --- a/test/test_baidu.js +++ b/test/test_baidu.js @@ -1,5 +1,6 @@ +'use strict'; const se_scraper = require('./../index.js'); -var assert = require('chai').assert; +const assert = require('chai').assert; /* * Use chai and mocha for tests. @@ -80,6 +81,7 @@ function normal_search_test_case(response) { } } -(async () => { - await normal_search_test(); -})(); \ No newline at end of file +describe('Baidu', function(){ + this.timeout(30000); + it('normal search test', normal_search_test); +}); \ No newline at end of file diff --git a/test/test_bing.js b/test/test_bing.js index 56b1993..b5faff1 100644 --- a/test/test_bing.js +++ b/test/test_bing.js @@ -1,3 +1,4 @@ +'use strict'; const se_scraper = require('./../index.js'); const chai = require('chai'); chai.use(require('chai-string')); @@ -114,7 +115,6 @@ async function no_results_test() { function test_case_no_results(response) { assert.equal(response.metadata.num_requests, 1); - results = response.results; for (let query in response.results) { assert.containsAllKeys(response.results, keywords_no_results, 'not all keywords were scraped.'); @@ -163,7 +163,6 @@ async function effective_query_test() { function test_case_effective_query(response) { assert.equal(response.metadata.num_requests, 1); - results = response.results; for (let query in response.results) { assert.containsAllKeys(response.results, effective_query_keywords, 'not all keywords were scraped.'); diff --git a/test/test_duckduckgo.js b/test/test_duckduckgo.js index 4530faf..39efe6e 100644 --- a/test/test_duckduckgo.js +++ b/test/test_duckduckgo.js @@ -1,3 +1,4 @@ +'use strict'; const se_scraper = require('./../index.js'); const chai = require('chai'); chai.use(require('chai-string')); diff --git a/test/test_google.js b/test/test_google.js index c9c49d4..eec387d 100644 --- a/test/test_google.js +++ b/test/test_google.js @@ -1,3 +1,4 @@ +'use strict'; const se_scraper = require('./../index.js'); const chai = require('chai'); chai.use(require('chai-string')); @@ -110,7 +111,6 @@ async function no_results_test() { function test_case_no_results(response) { assert.equal(response.metadata.num_requests, 1); - results = response.results; for (let query in response.results) { assert.containsAllKeys(response.results, keywords_no_results, 'not all keywords were scraped.'); @@ -123,7 +123,7 @@ function test_case_no_results(response) { assert.containsAllKeys(obj, ['results', 'time', 'no_results', 'num_results', 'effective_query'], 'not all keys are in the object'); - assert(obj.results.length === 0, 'results must have 0 SERP objects'); + assert.strictEqual(obj.results.length, 0, 'results must have 0 SERP objects'); assert.equal(obj.no_results, true, 'no results should be true'); assert.isEmpty(obj.num_results, 'no results should be a empty string'); assert.typeOf(Date.parse(obj.time), 'number', 'time should be a valid date'); diff --git a/test/test_googleimage.js b/test/test_googleimage.js index f2b50e5..31f00e9 100644 --- a/test/test_googleimage.js +++ b/test/test_googleimage.js @@ -1,5 +1,6 @@ +'use strict'; const se_scraper = require('./../index.js'); -var assert = require('chai').assert; +const assert = require('chai').assert; /* * Use chai and mocha for tests. @@ -73,6 +74,7 @@ function normal_image_search_test_case(response) { } } -(async () => { - await normal_image_search_test(); -})(); \ No newline at end of file +describe('Google Image', function(){ + this.timeout(30000); + it('normal image search test', normal_image_search_test); +}); \ No newline at end of file diff --git a/test/test_queryargs_google.js b/test/test_queryargs_google.js index cd4629b..d4b51db 100644 --- a/test/test_queryargs_google.js +++ b/test/test_queryargs_google.js @@ -1,5 +1,6 @@ +'use strict'; const se_scraper = require('./../index.js'); -var assert = require('chai').assert; +const assert = require('chai').assert; const normal_search_keywords = ['apple juice']; @@ -84,6 +85,7 @@ function queryargs_search_test_case(err, response) { } } -(async () => { - await queryargs_search_test(); -})(); +describe('Google with query arguments', function(){ + this.timeout(30000); + it('query args search test', queryargs_search_test); +}); diff --git a/test/test_ticker_search.js b/test/test_ticker_search.js index be19858..f8a379f 100644 --- a/test/test_ticker_search.js +++ b/test/test_ticker_search.js @@ -1,5 +1,6 @@ +'use strict'; const se_scraper = require('./../index.js'); -var assert = require('chai').assert; +const assert = require('chai').assert; /* * Use chai and mocha for tests. @@ -208,8 +209,9 @@ function marketwatch_search_test_case(err, response) { } -(async () => { - await reuters_search_test(); - await cnbc_search_test(); - await marketwatch_search_test(); -})(); \ No newline at end of file +describe('Ticker', function(){ + this.timeout(30000); + it('Reuters search test', reuters_search_test); + it('CNBC search test', cnbc_search_test); + it('Marketwatch search test', marketwatch_search_test); +}); \ No newline at end of file