Unit test with moment.js : <p>I'm new to writing unit tests and need some help testing part of a function.</p>

<p>My function looks like this...</p>

<pre><code>getData() {
return this.parameters.map(p =&gt; {
        return {
            name: p.name,
            items: p.items.map(item =&gt; {

                const toTime = item.hasOwnProperty('end') ? moment.utc(item.end._d).unix() : null;
                const fromTime = item.hasOwnProperty('start') ? moment.utc(item.start._d).unix() : null;

                return {
                    id: item.id,
                    fromTime: fromTime,
                    toTime: toTime,
                };
            }),
        };
    });
}
</code></pre>

<p>and so far my test looks like this (jasmine)</p>

<pre><code>describe('getData()', function() {
it('should return json data', function() {
    $ctrl.parameters = [{
        name: 'test',
        items: [{
            id: 1,
            fromTime: null,
            toTime: null
        }, {
            id: 13,
            fromTime: null,
            toTime: null

        }]
    }];

    expect($ctrl.getData()).toEqual([{
        name: 'test',
        items: [{
            id: 1,
            fromTime: null,
            toTime: null
        }, {
            id: 13,
            fromTime: null,
            toTime: null
        }]
    }]);
});
});
</code></pre>

<p>This test is working/passing, but as you can see I am not testing the ternary if/else that uses Moment.js. Basically what the ternary does is check if items contains a property called <code>start</code> / <code>end</code> and if it does, convert that value to a epoch/unix timestamp and assign it to either <code>toTime</code> or <code>fromTime</code>. So if items had a property called end with a value of <code>'Sat Oct 31 2015 00:00:00 GMT+0000 (GMT)'</code>, then it would be converted to <code>'1446249600'</code> and assigned to <code>toTime</code> </p>

<p>Hopefully that explains it! I'm not sure how to write a test for it and would appreciate any help/suggestions. </p>
