<commit_before>'use strict';

var chai = require('chai');
var expect = chai.expect;
chai.Assertion.includeStack = true;

var api = require('../src/api.js');
var problems = null;

var _ = require('underscore'),
    fs = require('fs'), path = require('path');

var problemsFile = path.join(__dirname, '../problems.json');

before(function (done) {
    fs.exists(problemsFile, function (exists) {
        if (!exists) {
            api.problems(function (body) {
                problems = _.sortBy(body, function (p) {
                    return p.size;
                });
                fs.writeFileSync(problemsFile, JSON.stringify(problems, null, '\t'));
                done();
            });
        } else {
            fs.readFile(problemsFile, function (err, data) {
                if (err) throw err;
                problems = JSON.parse(data);
                done();
            });
        }
    });
});

describe('ICFP cloudapp.net endpoint', function () {
    it('should load problems', function () {
        expect(problems.length).to.equal(1420);
        expect(problems[0].size).to.equal(3);
        expect(problems[problems.length - 1].size).to.equal(30);<commit_msg>tiny testfix (more tasks available)<commit_after>'use strict';

var chai = require('chai');
var expect = chai.expect;
chai.Assertion.includeStack = true;

var api = require('../src/api.js');
var problems = null;

var _ = require('underscore'),
    fs = require('fs'), path = require('path');

var problemsFile = path.join(__dirname, '../problems.json');

before(function (done) {
    fs.exists(problemsFile, function (exists) {
        if (!exists) {
            api.problems(function (body) {
                problems = _.sortBy(body, function (p) {
                    return p.size;
                });
                fs.writeFileSync(problemsFile, JSON.stringify(problems, null, '\t'));
                done();
            });
        } else {
            fs.readFile(problemsFile, function (err, data) {
                if (err) throw err;
                problems = JSON.parse(data);
                done();
            });
        }
    });
});

describe('ICFP cloudapp.net endpoint', function () {
    it('should load problems', function () {
        expect(problems.length).to.equal(1620);
        expect(problems[0].size).to.equal(3);
        expect(problems[problems.length - 1].size).to.equal(30);
{'fraction_non_alphanumeric': 0.15679733110925773, 'fraction_numerical': 0.007506255212677231, 'mean_word_length': 2.1034928848641656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3050279', 'n_tokens_mistral': 740, 'n_tokens_neox': 694, 'n_words': 143}