/**
 * Created by cwouter on 1/3/2020.
 */
var CrossUp = require('../../lib/Utils/CrossUp').CrossUp;
var assert = require('assert');

var input = {
    lineA: [3, 4, 5, 6, 7, 2, 7, 5, 7, 2, 5, 5, 7, 2, 5, 5, 2, 7],
    lineB: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
};

var expectedResults = [false, false, false, true, false, false, true, false, false, false, false, false, true, false, false, false, false, true];

describe('Cross Up', function() {
    'use strict';
    it('should calculate positive line cross over using the calculate method', function() {
        assert.deepEqual(CrossUp.calculate(input), expectedResults);
    });

    it('should calculate positive line cross over by using getResult', function() {
        var crossUp = new CrossUp(input);
        assert.deepEqual(crossUp.getResult(), expectedResults, 'Wrong Results while calculating next bar');
    });

    it('should calculate positive line cross over by using nextValue', function() {
        var crossUp = new CrossUp({lineA: [], lineB: []});
        var results = [];
        input.lineA.forEach((value, index) => {
            var result = crossUp.nextValue(input.lineA[index], input.lineB[index]);
            results.push(result)
        });
        assert.deepEqual(results, expectedResults, 'Wrong Results while getting results');
    })
});


