<commit_before>var should = require('should');
var scraper = require('../index');

describe('Node e-commerce scraper', function () {

    it('should get an e-commerce url and return the html', function (done) {

        scraper.get('http://www.google.com', function (err, $) {
            $.should.be.ok;

            $('body').length.should.be.above(0);

            done();
        });

    });

    it('should return a valid list of product attributes', function (done) {

        var url = 'http://www.dafiti.com.br/Camiseta-Lee-Vermelha-1680307.html';

        var options = {
            images: '#gallery .carousel-item > a',
            name: 'h1.product-name',
            description: 'p.product-information-description',
            price: '.catalog-detail-full-price .catalog-detail-price-value'
        };

        scraper.get(url, options, function (err, data, $) {
            data.should.be.ok;

            data.images.should.be.an.Array;
            data.images.length.should.be.eql(4);

            data.name.should.be.a.String;
            data.name.should.be.eql('<NAME>');

            data.description.should.be.a.String;

            data.price.should.be.a.Number;
            data.price.should.be.eql(119);

            done();
        });

    });

});<commit_msg>Add test case for objects instead of selector string.<commit_after>var should = require('should');
var scraper = require('../index');

describe('Node e-commerce scraper', function () {

    it('should get an e-commerce url and return the html', function (done) {

        scraper.get('http://www.google.com', function (err, $) {
            $.should.be.ok;

            $('body').length.should.be.above(0);

            done();
        });

    });

    it('should return a valid list of product attributes', function (done) {

        var url = 'http://www.dafiti.com.br/Camiseta-Lee-Vermelha-1680307.html';

        var options = {
            images: '#gallery .carousel-item > a',
            name: 'h1.product-name',
            description: 'p.product-information-description',
            price: '.catalog-detail-full-price .catalog-detail-price-value'
        };

        scraper.get(url, options, function (err, data, $) {
            data.should.be.ok;

            data.images.should.be.an.Array;
            data.images.length.should.be.eql(4);

            data.name.should.be.a.String;
            data.name.should.be.eql('<NAME>');

            data.description.should.be.a.String;

            data.price.should.be.a.Number;
            data.price.should.be.eql(119);

            done();
        });

    });

    it('should work with objects and selector strings', function (done) {

        var url = 'http://www.zattini.com.br/produto/sapatenis-polo-hpc-190-D93-0005-010';

        var options = {
            images: {
                selector: '#gallery .carousel-item > a',
                attribute: 'data-zoom'
            },
            name: 'h1.base-title',
            description: 'div.product-description',
            price: '.product-info-holder [itemprop="price"]'
        };

        scraper.get(url, options, function (err, data, $) {
            console.log(data);

            data.should.be.ok;

            data.images.should.be.an.Array;
            data.images.length.should.be.eql(5);

            data.name.should.be.a.String;
            data.name.should.be.eql('Sapatênis Polo HPC 190');

            data.description.should.be.a.String;

            data.price.should.be.a.Number;
            data.price.should.be.eql(239.9);

            done();
        });

    });

});
{'fraction_non_alphanumeric': 0.15599889165973954, 'fraction_numerical': 0.013022998060404543, 'mean_word_length': 1.7919566898685229, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1945157', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1084, 'n_words': 188}