<commit_before>'use strict';

const preq = require('preq');
const assert = require('../../utils/assert');
const server = require('../../utils/server');
const checkHeaders = require('../../utils/headers').checkHeaders;
const contentType = require('../../utils/headers').CSS_CONTENT_TYPE_REGEX;
const css = require('../../../lib/css').testing;

const localUri = path => `${server.config.uri}meta.wikimedia.org/v1/data/css/mobile${path}`;

describe('css', function() {

    this.timeout(20000); // eslint-disable-line no-invalid-this

    before(() => server.start());

    it('/base should respond to GET request with expected headers', () => {
        return checkHeaders(localUri('/base'), contentType, 'cache-control');
    });

    it('/site should respond to GET request with expected headers', () => {
        return checkHeaders(localUri('/site'), contentType, 'cache-control');
    });

    it('/base response should have nonzero length', () => {
        return preq.get(localUri('/base')).then(res => assert.ok(res.body.length > 0));
    });

    it('/site response should have nonzero length', () => {
        return preq.get(localUri('/site')).then(res => assert.ok(res.body.length > 0));
    });

    it('default RL request wiki uses canonical domain (request should not redirect)', () => {
        return css.load(css.BASE_MODULES).then(res => assert.ok(!res.headers['content-location']));
    });

});
<commit_msg>Hygiene: refactor css test<commit_after>'use strict';

const preq = require('preq');
const assert = require('../../utils/assert');
const server = require('../../utils/server');
const checkHeaders = require('../../utils/headers').checkHeaders;
const contentType = require('../../utils/headers').CSS_CONTENT_TYPE_REGEX;
const css = require('../../../lib/css').testing;

const localUri = path => `${server.config.uri}meta.wikimedia.org/v1/data/css/mobile${path}`;

describe('css', function() {

    this.timeout(20000); // eslint-disable-line no-invalid-this

    before(() => server.start());

    ['/base', '/site'].forEach((cssType) => {
        it(`${cssType} should respond to GET request with expected headers`, () => {
            return checkHeaders(localUri(cssType), contentType, 'cache-control');
        });

        it(`${cssType} response should have non-zero length`, () => {
            return preq.get(localUri(cssType)).then(res => assert.ok(res.body.length > 0));
        });
    });

    it('default RL request wiki uses canonical domain (request should not redirect)', () => {
        return css.load(css.BASE_MODULES).then(res => assert.ok(!res.headers['content-location']));
    });

});

{'fraction_non_alphanumeric': 0.2012148823082764, 'fraction_numerical': 0.0056947608200455585, 'mean_word_length': 3.511986301369863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '4478764', 'n_tokens_mistral': 773, 'n_tokens_neox': 750, 'n_words': 164}