<commit_before>/* eslint-disable */

var assert = require('chai').assert;
var app = require('../app');
var eris = require(__libs+'/eris/eris-wrapper');
var taskManager = require('../js/taskManager');

describe("Task Manager", function () {

    describe("addTask", function () {
        it("adds the given task to the chain and returns true if a record was overwritten, false otherwise", function(done) {
            var testTask = {
                id: eris.str2hex("test1"),
                title: eris.str2hex("TestTitle"),
                desc: eris.str2hex("Test Description"),
                status: eris.str2hex("To Do"),
                complete: eris.str2hex("0/?"),
                reward: eris.str2hex("200")
            };
            taskManager.addTask(testTask, function (error, result) {
                assert.isNull(error);
                // TODO reactivate this and the inverse when deletion is implemented
                // assert.equal(result, false, "no overwrite on first pass => false");
                done();
            });
        });
    });

    describe("getTaskAtIndex", function () {
        it("returns the address of the task at the passed index and its `nextIndex` indicator", function (done) {
            taskManager.getTaskAtIndex(0, function (error, data) {
                assert.isNull(error);
                assert.notEqual(data[0], null, "returned address should never be null");
                assert.notEqual(data[1], null, "returned nextIdx should never be null");
                done();
            })
        })
    })

    describe("getTaskListSize", function () {
        it("returns the current total size of the task list map", function (done) {
            taskManager.getTaskListSize(function (error, size) {
                assert.isNull(error);
                assert.notEqual(size, null, "`size` should return 0 or greater");
                done();
            })
        })
    });

    describe("getAllTasks", function () {
       it("retrieves all tasks from the given start index onwards", function (done) {
           taskManager.getAllTasks(function (addresses) {
               assert.isNotNull(addresses, "`addresses` array should not be null");
               assert.isAtLeast(addresses.length, 1, "There should be at least 1 element from running the `addTask` test");
               done();
           });
       })
    });

});
<commit_msg>Adds unit test for getTaskAtAddress<commit_after>/* eslint-disable */

var assert = require('chai').assert;
var app = require('../app');
var eris = require(__libs+'/eris/eris-wrapper');
var taskManager = require('../js/taskManager');

var refAddr;

describe("Task Manager", function () {

    describe("addTask", function () {
        it("adds the given task to the chain and returns true if a record was overwritten, false otherwise", function(done) {
            var testTask = {
                id: eris.str2hex("test1"),
                title: eris.str2hex("TestTitle"),
                desc: eris.str2hex("Test Description"),
                status: eris.str2hex("To Do"),
                complete: eris.str2hex("0/?"),
                reward: eris.str2hex("200")
            };
            taskManager.addTask(testTask, function (error, result) {
                assert.isNull(error);
                // TODO reactivate this and the inverse when deletion is implemented
                // assert.equal(result, false, "no overwrite on first pass => false");
                done();
            });
        });
    });

    describe("getTaskAtIndex", function () {
        it("returns the address of the task at the passed index and its `nextIndex` indicator", function (done) {
            taskManager.getTaskAtIndex(0, function (error, data) {
                assert.isNull(error);
                assert.notEqual(data[0], null, "returned address should never be null");
                assert.notEqual(data[1], null, "returned nextIdx should never be null");
                done();
            })
        })
    })

    describe("getTaskListSize", function () {
        it("returns the current total size of the task list map", function (done) {
            taskManager.getTaskListSize(function (error, size) {
                assert.isNull(error);
                assert.notEqual(size, null, "`size` should return 0 or greater");
                done();
            })
        })
    });

    describe("getAllTasks", function () {
       it("retrieves all tasks from the given start index onwards", function (done) {
           taskManager.getAllTasks(function (addresses) {
               assert.isNotNull(addresses, "`addresses` array should not be null");
               assert.isAtLeast(addresses.length, 1, "There should be at least 1 element from running the `addTask` test");
               refAddr = addresses[0];
               done();
           });
       })
    });

    describe("getTaskAtAddress", function () {
        it("retrieves the task contract registered at the passed address and transforms it into a task object", function (done) {
            var taskType = [ 'address', 'status', 'reward', 'title', 'complete', 'desc', 'id' ];

            taskManager.getTaskAtAddress(refAddr, function (err, task) {
                assert.isNull(err);
                assert.notDeepEqual(task, {}, "returned task object should not be empty");
                assert.sameMembers(Object.keys(task), taskType, "returned task object's keys should adhere to Task type");
                done();
            });
        });
    });

});

{'fraction_non_alphanumeric': 0.12464080459770115, 'fraction_numerical': 0.006285919540229885, 'mean_word_length': 2.063256325632563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '99415', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1419, 'n_words': 424}