<commit_before>const test = require('tape');
const proxyquire = require('proxyquire');

function setupChecker(mocks) {
    return proxyquire('./checkSystem', mocks);
}

test('checkSystem', (t) => {

    t.test('throws when no package.json is present', (t) => {
        const checkSystem = setupChecker({
            fs: {
                accessSync: () => {
                    throw 'File not found!';
                }
            }
        });

        checkSystem().then((result) => {
            t.equal(result.status, -1);
            t.end();
        });
    });
});<commit_msg>added a test to check the non-existence of the engines key<commit_after>const test = require('tape');
const proxyquire = require('proxyquire');

const MockFile = require('../test/MockFile');

function setupChecker(mocks) {
    return proxyquire('./checkSystem', mocks);
}

test('checkSystem', (t) => {

    t.test('throws when no package.json is present', (t) => {
        const checkSystem = setupChecker({
            fs: {
                accessSync: () => {
                    throw 'File not found!';
                }
            }
        });

        checkSystem().then((result) => {
            t.equal(result.status, -1);
            t.end();
        });
    });

    t.test('throws when no engines key is present', (t) => {
        const checkSystem = setupChecker({
            fs: { accessSync: () => 0 }
        });

        let mf = new MockFile('./testPackage.json', {});

        checkSystem(mf.path).then((result) => {
            t.equal(result.status, -1);

            mf.delete();
            mf = undefined;
            t.end();
        });
    });
});
{'fraction_non_alphanumeric': 0.16375677302829622, 'fraction_numerical': 0.002408187838651415, 'mean_word_length': 1.7516556291390728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '3792347', 'n_tokens_mistral': 477, 'n_tokens_neox': 463, 'n_words': 104}