<commit_before>'use strict';

// mocha defines to avoid JSHint breakage
/* global describe, it, before, beforeEach, after, afterEach */

var fs = require('fs');
var yaml = require('js-yaml');

var assert = require('assert');
var Router = require('../../../lib/router');
var router = new Router();

var rootSpec = {
    paths: {
        '/{domain:en.wikipedia.org}/v1': {
            'x-restbase': {
                specs: [
                    'mediawiki/v1/content'
                ]
            }
        }
    }
};

var faultySpec = {
    paths: {
        '/{domain:en.wikipedia.org}': {
            'x-restbase': {
                specs: [
                    {
                        paths: {},
                        'x-restbase-paths': {
                            '/notsys/foo': {}
                        }
                    }
                ]
            }
        }
    }
};

var fullSpec = yaml.safeLoad(fs.readFileSync('config.example.yaml'));

describe('tree building', function() {
    it('should build a simple spec tree', function() {
        router.loadSpec(rootSpec);
        //console.log(JSON.stringify(router.tree, null, 2));
        var handler = router.route('/en.wikipedia.org/v1/page/Foo/html');
        //console.log(handler);
        assert.equal(!!handler.value.methods.get, true);
        assert.equal(handler.params.domain, 'en.wikipedia.org');
        assert.equal(handler.params.title, 'Foo');
    });

    it('should fail loading a faulty spec', function() {
        assert.throws(function() {
            router.loadSpec(faultySpec);
        }, Error);
    });

    it('should build the example config spec tree', function() {
        router.loadSpec(fullSpec.spec);
        //console.log(JSON.stringify(router.tree, null, 2));
        var handler = router.route('/en.wikipedia.org/v1/page/Foo/html');
        //console.log(handler);
        assert.equal(!!handler.value.methods.get, true);
        assert.equal(handler.params.domain, 'en.wikipedia.org');
        assert.equal(handler.params.title, 'Foo');
    });
});

module.exports = function () {};
<commit_msg>T76883: Minor: Tests: provide a dummy test, but do not load content.yaml<commit_after>'use strict';

// mocha defines to avoid JSHint breakage
/* global describe, it, before, beforeEach, after, afterEach */

var fs = require('fs');
var yaml = require('js-yaml');

var assert = require('assert');
var Router = require('../../../lib/router');
var router = new Router();

var rootSpec = {
    paths: {
        '/{domain:en.wikipedia.org}/v1': {
            'x-restbase': {
                specs: [
                    {
                        paths: {
                            '/page/{title}/html': {
                                get: {
                                    'x-restbase': {
                                        service: {
                                            uri: '/{domain}/sys/parsoid/html/{title}/latest'
                                        }
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        }
    }
};

var faultySpec = {
    paths: {
        '/{domain:en.wikipedia.org}': {
            'x-restbase': {
                specs: [
                    {
                        paths: {},
                        'x-restbase-paths': {
                            '/notsys/foo': {}
                        }
                    }
                ]
            }
        }
    }
};

var fullSpec = yaml.safeLoad(fs.readFileSync('config.example.yaml'));

describe('tree building', function() {
    it('should build a simple spec tree', function() {
        router.loadSpec(rootSpec);
        //console.log(JSON.stringify(router.tree, null, 2));
        var handler = router.route('/en.wikipedia.org/v1/page/Foo/html');
        //console.log(handler);
        assert.equal(!!handler.value.methods.get, true);
        assert.equal(handler.params.domain, 'en.wikipedia.org');
        assert.equal(handler.params.title, 'Foo');
    });

    it('should fail loading a faulty spec', function() {
        assert.throws(function() {
            router.loadSpec(faultySpec);
        }, Error);
    });

    it('should build the example config spec tree', function() {
        router.loadSpec(fullSpec.spec);
        //console.log(JSON.stringify(router.tree, null, 2));
        var handler = router.route('/en.wikipedia.org/v1/page/Foo/html');
        //console.log(handler);
        assert.equal(!!handler.value.methods.get, true);
        assert.equal(handler.params.domain, 'en.wikipedia.org');
        assert.equal(handler.params.title, 'Foo');
    });
});

module.exports = function () {};

{'fraction_non_alphanumeric': 0.1514069718605628, 'fraction_numerical': 0.0033599328013439733, 'mean_word_length': 1.4768590743629746, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4208244', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1282, 'n_words': 233}