<commit_before>/*global casper*/
/*jshint strict:false*/
var fs = require('fs'), testFile = '/tmp/__casper_test_capture.png';

if (fs.exists(testFile) && fs.isFile(testFile)) {
    fs.remove(testFile);
}

casper.start('tests/site/index.html', function() {
    this.viewport(300, 200);
    this.test.comment('Casper.capture()');
    this.capture(testFile);
    this.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot');
});

casper.thenOpen('tests/site/index.html', function() {
    this.test.comment('Casper.captureBase64()');
    this.test.assert(this.captureBase64('png').length > 0,
                     'Casper.captureBase64() rendered a page capture as base64');
    this.test.assert(this.captureBase64('png', 'ul').length > 0,
                     'Casper.captureBase64() rendered a capture from a selector as base64');
    this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0,
                     'Casper.captureBase64() rendered a capture from a clipRect as base64');
});

casper.run(function() {
    try {
        fs.remove(testFile);
    } catch(e) {}
    this.test.done(4);
});<commit_msg>migrated casper/capture tests to new testing format<commit_after>/*global casper*/
/*jshint strict:false*/
var fs = require('fs'),
    testFile = '/tmp/__casper_test_capture.png';

if (fs.exists(testFile) && fs.isFile(testFile)) {
    fs.remove(testFile);
}

casper.test.begin('Casper.capture() tests', 1, function(test) {
    casper.start('tests/site/index.html', function() {
        this.viewport(300, 200);
        this.capture(testFile);
        test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot');
    }).run(function() {
        try {
            fs.remove(testFile);
        } catch(e) {
            this.warn('Unable to delete test file ' + testFile + '; please delete it manually');
        }
        test.done();
    });
});

casper.test.begin('Casper.captureBase64() tests', 3, function(test) {
    casper.start('tests/site/index.html', function() {
        test.assert(this.captureBase64('png').length > 0,
                         'Casper.captureBase64() rendered a page capture as base64');
        test.assert(this.captureBase64('png', 'ul').length > 0,
                         'Casper.captureBase64() rendered a capture from a selector as base64');
        test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0,
                         'Casper.captureBase64() rendered a capture from a clipRect as base64');
    }).run(function() {
        test.done();
    });
});
{'fraction_non_alphanumeric': 0.16596397087006515, 'fraction_numerical': 0.02798006899195094, 'mean_word_length': 3.003067484662577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4799279', 'n_tokens_mistral': 872, 'n_tokens_neox': 814, 'n_words': 168}