<commit_before>var fs = require('fs');
var request = require('supertest');
var parse = require('../lib/parse.js');
var app = require('../lib/server/server');
var chai = require("chai");
var eyes = require('eyes');
var should = chai.should();

describe('Listing Details Examples: Answers to multiple listing details by example questions.', function () {
    this.timeout(0)

    var result_json_q1 = fs.readFileSync(__dirname +
        '/../fixtures/examples/listing/q1.json', 'utf-8');

    var result_json_q2 = fs.readFileSync(__dirname +
        '/../fixtures/examples/listing/q2.json', 'utf-8');

    it('q1: It should search for the Google+ app by its title' +
        'and find two versions of the app: "413076433" and "413148638".',
        function (done) {
            var listing_query = '<title>Google+</title>'
            var q = 'MATCH app\nWHERE\n' + listing_query + '\n RETURN app';
            var expected = JSON.parse(result_json_q1);
            request(app)
                .get('/q/json')
                .query({queryText: q})
                .set('Accept', 'application/json')
                .expect(200)
                .end(function (err, res) {
                    should.not.exist(err);
                    should.exist(res.body);
                    res.body.should.have.length(2);
                    try {
                        res.body.should.deep.include.members(expected);
                    }
                    catch (e) {
                        console.log('Expected:')
                        eyes.inspect(expected)
                        console.log('Actual:')
                        eyes.inspect(res.body)
                        throw e
                    }
                    done()
                });
        })

    it('q2: It should search for apps with downloads count between of 500,000,000' +
        ' and 1,000,000,000 and find 13 apps.',
        function (done) {
            var listing_query = '<downloads-count-text>500,000,000 - 1,000,000,000</downloads-count-text>'
            var q = 'MATCH app\nWHERE\n' + listing_query + '\n RETURN app';
            var expected = JSON.parse(result_json_q2);
            request(app)
                .get('/q/json')
                .query({queryText: q})
                .set('Accept', 'application/json')
                .expect(200)
                .end(function (err, res) {
                    should.not.exist(err);
                    should.exist(res.body);
                    res.body.should.have.length(13);
                    try {
                        res.body.should.deep.include.members(expected);
                    }
                    catch (e) {
                        console.log('Expected:')
                        eyes.inspect(expected)
                        console.log('Actual:')
                        eyes.inspect(res.body)
                        throw e
                    }
                    done()
                });
        })


})<commit_msg>add test for multiple listing fields<commit_after>var fs = require('fs');
var request = require('supertest');
var parse = require('../lib/parse.js');
var app = require('../lib/server/server');
var chai = require("chai");
var eyes = require('eyes');
var should = chai.should();

describe('Listing Details Examples: Answers to multiple listing details by example questions.', function () {
    this.timeout(0)

    var result_json_q1 = fs.readFileSync(__dirname +
        '/../fixtures/examples/listing/q1.json', 'utf-8');
    var result_json_q2 = fs.readFileSync(__dirname +
        '/../fixtures/examples/listing/q2.json', 'utf-8');
    var result_json_q3 = fs.readFileSync(__dirname +
        '/../fixtures/examples/listing/q3.json', 'utf-8');
    var result_json_q4 = fs.readFileSync(__dirname +
        '/../fixtures/examples/listing/q4.json', 'utf-8');

    it('q1: It should search for the Google+ app by its title' +
        'and find two versions of the app: "413076433" and "413148638".',
        function (done) {
            var listing_query = '<title>Google+</title>'
            var q = 'MATCH app\nWHERE\n' + listing_query + '\n RETURN app';
            var expected = JSON.parse(result_json_q1);
            request(app)
                .get('/q/json')
                .query({queryText: q})
                .set('Accept', 'application/json')
                .expect(200)
                .end(function (err, res) {
                    should.not.exist(err);
                    should.exist(res.body);
                    res.body.should.have.length(2);
                    try {
                        res.body.should.deep.include.members(expected);
                    }
                    catch (e) {
                        console.log('Expected:');
                        eyes.inspect(expected);
                        console.log('Actual:');
                        eyes.inspect(res.body);
                        throw e
                    }
                    done()
                });
        })

    it('q2: It should search for apps with downloads count between of 500,000,000' +
        ' and 1,000,000,000 and find 13 apps.',
        function (done) {
            var listing_query = '<downloads-count-text>500,000,000 - 1,000,000,000</downloads-count-text>'
            var q = 'MATCH app\nWHERE\n' + listing_query + '\n RETURN app';
            var expected = JSON.parse(result_json_q2);
            request(app)
                .get('/q/json')
                .query({queryText: q})
                .set('Accept', 'application/json')
                .expect(200)
                .end(function (err, res) {
                    should.not.exist(err);
                    should.exist(res.body);
                    res.body.should.have.length(13);
                    try {
                        res.body.should.deep.include.members(expected);
                    }
                    catch (e) {
                        console.log('Expected:');
                        eyes.inspect(expected);
                        console.log('Actual:');
                        eyes.inspect(res.body);
                        throw e
                    }
                    done()
                });
        })

    it('q3: It should search for apps with the word PDF ' +
        'in their listing details using the full text index ' +
        'and find 2 apps.',
        function (done) {
            var listing_query = '<listing-details>PDF</listing-details>'
            var q = 'MATCH app\nWHERE\n' + listing_query + '\n RETURN app';
            var expected = JSON.parse(result_json_q3);
            request(app)
                .get('/q/json')
                .query({queryText: q})
                .set('Accept', 'application/json')
                .expect(200)
                .end(function (err, res) {
                    should.not.exist(err);
                    should.exist(res.body);
                    res.body.should.have.length(2);
                    try {
                        res.body.should.deep.include.members(expected);
                    }
                    catch (e) {
                        console.log('Expected:');
                        eyes.inspect(expected);
                        console.log('Actual:');
                        eyes.inspect(res.body);
                        throw e
                    }
                    done()
                });
        })

    it('q4: It should search for apps by providing multiple listing details ' +
        'fields using the full text index along with absolute values search.',
        function (done) {
            var listing_query = '<description>Hats and Eyeglasses</description>'
                + '<price>Free</price>'
                + '<store-category>Casual</store-category>';
            var q = 'MATCH app\nWHERE\n' + listing_query + '\n RETURN app';
            var expected = JSON.parse(result_json_q4);
            request(app)
                .get('/q/json')
                .query({queryText: q})
                .set('Accept', 'application/json')
                .expect(200)
                .end(function (err, res) {
                    should.not.exist(err);
                    should.exist(res.body);
                    res.body.should.have.length(1);
                    try {
                        res.body.should.deep.include.members(expected);
                    }
                    catch (e) {
                        console.log('Expected:');
                        eyes.inspect(expected);
                        console.log('Actual:');
                        eyes.inspect(res.body);
                        throw e
                    }
                    done()
                });
        })

})
{'fraction_non_alphanumeric': 0.12524282939092676, 'fraction_numerical': 0.019997714546908924, 'mean_word_length': 1.25508889461479, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4414635', 'n_tokens_mistral': 2474, 'n_tokens_neox': 2225, 'n_words': 472}