Meteor change consts during unit-test

I have wrote simple unit test. The part of it is:

import { Meteor } from 'meteor/meteor';
import { expect } from 'chai';
import { Mongo } from 'meteor/mongo';
import { Notifications } from './../notifications';

const nOne =  {
    userId: 445566,
    post: {
        _id: 'postId',
        image: 'image URL',
        text: 'text of the post',
        company_name: 'text',
        company_source: 'someURL'
    },
    coords: {latitude:59, longitude:30}
}

if (Meteor.isServer) {
    describe ('notifications ', function () {

        beforeEach(function() {
            Notifications.remove({});
        });


      
        it ('some test', function () {

            Meteor.server.method_handlers['notifications.add'].apply({},[nOne]);
            
        });


    })
}

And the problem is that nOne.coords before the test is {latitude:59, longitude:30}
but after call meteor method it [{latitude:59, longitude:30}] - an array;

how is it possible that Meteor method change const. And change it from Object to [Object] ?

No sure what code is changing this, but object properties and array items β€˜can’ be changed. This is not a Meteor thing, but an Ecmascript thing.

Indeed. You just cannot reassign something that has been declared const.

In that regard, use of the const keyword is a bit … unfortunate.

1 Like

But how Meteor handler can change the variable? I just apply it