Sha256: b6d42aee627b68c5307fd36e6dc04c7b55414405306afb2925f380131e01d71b

Contents?: true

Size: 1.37 KB

Versions: 27

Compression:

Stored size: 1.37 KB

Contents

import { module, test } from '../qunit';
import moment from '../../moment';

module('to type');

test('toObject', function (assert) {
    var expected = {
        years:2010,
        months:3,
        date:5,
        hours:15,
        minutes:10,
        seconds:3,
        milliseconds:123
    };
    assert.deepEqual(moment(expected).toObject(), expected, 'toObject invalid');
});

test('toArray', function (assert) {
    var expected = [2014, 11, 26, 11, 46, 58, 17];
    assert.deepEqual(moment(expected).toArray(), expected, 'toArray invalid');
});

test('toDate returns a copy of the internal date', function (assert) {
    var m = moment();
    var d = m.toDate();
    m.year(0);
    assert.notEqual(d, m.toDate());
});

test('toJSON', function (assert) {
    if (Date.prototype.toISOString) {
        var expected = new Date().toISOString();
        assert.deepEqual(moment(expected).toJSON(), expected, 'toJSON invalid');
    } else {
        // IE8
        assert.expect(0);
    }
});

test('toJSON works when moment is frozen', function (assert) {
    if (Date.prototype.toISOString) {
        var expected = new Date().toISOString();
        var m = moment(expected);
        if (Object.freeze != null) {
            Object.freeze(m);
        }
        assert.deepEqual(m.toJSON(), expected, 'toJSON when frozen invalid');
    } else {
        // IE8
        assert.expect(0);
    }
});

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
card-1.100.0 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.6 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.5 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.4 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.3 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.2 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.1 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.99.0 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.98.3 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.98.2 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.98.1 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.98.0 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.97.0.1 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.97.0 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.96.8 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.96.7 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.96.6 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.96.5 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.96.4 mod/date/vendor/moment/src/test/moment/to_type.js
card-1.96.3 mod/date/vendor/moment/src/test/moment/to_type.js