var Plotly = require('../src/plotly');

describe('Test heatmap', function () {
    'use strict';

    describe('supplyDefaults', function() {
        var traceIn,
            traceOut;

        var defaultColor = '#444',
            layout = {
                font: Plotly.Plots.layoutAttributes.font
            };

        var supplyDefaults = Plotly.Heatmap.supplyDefaults;

        beforeEach(function() {
            traceOut = {};
        });

        it('should set visible to false when z is empty', function() {
            traceIn = {
                z: []
            };
            supplyDefaults(traceIn, traceOut, defaultColor, layout);
            expect(traceOut.visible).toBe(false);

            traceIn = {
                z: [[]]
            };
            supplyDefaults(traceIn, traceOut, defaultColor, layout);
            expect(traceOut.visible).toBe(false);

            traceIn = {
                z: [[], [], []]
            };
            supplyDefaults(traceIn, traceOut, defaultColor, layout);
            expect(traceOut.visible).toBe(false);

            traceIn = {
                type: 'heatmap',
                z: [[1, 2], []]
            };
            traceOut = Plotly.Plots.supplyDataDefaults(traceIn, 0, layout);

            traceIn = {
                type: 'heatmap',
                z: [[], [1, 2], [1, 2, 3]]
            };
            traceOut = Plotly.Plots.supplyDataDefaults(traceIn, 0, layout);
            expect(traceOut.visible).toBe(true);
            expect(traceOut.visible).toBe(true);
        });

        it('should set visible to false when z is non-numeric', function() {
            traceIn = {
                type: 'heatmap',
                z: [['a', 'b'], ['c', 'd']]
            };
            supplyDefaults(traceIn, traceOut, defaultColor, layout);
            expect(traceOut.visible).toBe(false);
        });

    });

});

@@ -1873,24 +1873,1653 @@
        %7D);%0A%0A
+%0A    %7D);%0A%0A%0A    describe('calcColorscale', function() %7B%0A        var trace,%0A            z;%0A%0A        var calcColorscale = Plotly.Heatmap.calcColorscale;%0A%0A        beforeEach(function() %7B%0A            trace = %7B%7D;%0A            z = %7B%7D;%0A        %7D);%0A%0A        it('should be RdBuNeg when autocolorscale and z %3C= 0', function() %7B%0A            trace = %7B%0A                type: 'heatmap',%0A                z: %5B%5B0, -1.5%5D, %5B-2, -10%5D%5D,%0A                autocolorscale: true%0A            %7D;%0A            z = %5B%5B0, -1.5%5D, %5B-2, -10%5D%5D;%0A            calcColorscale(trace, z);%0A            expect(trace.autocolorscale).toBe(true);%0A            expect(trace.colorscale%5B5%5D).toEqual(%5B1, 'rgb(220, 220, 220)'%5D);%0A        %7D);%0A%0A        it('should be RdBuNeg when the only numerical z %3C= -0.5', function() %7B%0A            trace = %7B%0A                type: 'heatmap',%0A                z: %5B%5B'a', 'b'%5D, %5B-0.5, 'd'%5D%5D,%0A                autocolorscale: true%0A            %7D;%0A            z = %5B%5Bundefined, undefined%5D, %5B-0.5, undefined%5D%5D;%0A            calcColorscale(trace, z);%0A            expect(trace.autocolorscale).toBe(true);%0A            expect(trace.colorscale%5B5%5D).toEqual(%5B1, 'rgb(220, 220, 220)'%5D);%0A        %7D);%0A%0A        it('should be RdBuPos when the only numerical z %3E= 0.5', function() %7B%0A            trace = %7B%0A                type: 'heatmap',%0A                z: %5B%5B'a', 'b'%5D, %5B0.5, 'd'%5D%5D,%0A                autocolorscale: true%0A            %7D;%0A            z = %5B%5Bundefined, undefined%5D, %5B0.5, undefined%5D%5D;%0A            calcColorscale(trace, z);%0A            expect(trace.autocolorscale).toBe(true);%0A            expect(trace.colorscale%5B0%5D).toEqual(%5B0, 'rgb(220, 220, 220)'%5D);%0A        %7D);%0A%0A
     %7D);%0A%0A%7D);

Add tests for autocolorscale=true in particular cases