Skip to content

Commit

Permalink
Merge pull request #61 from nytamin/fix/Meteor.default_server
Browse files Browse the repository at this point in the history
fix: Replace Meteor.default_server with Meteor.server
  • Loading branch information
StorytellerCZ authored Jan 28, 2022
2 parents 8f4b79f + 695d51b commit 15b6e4c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions __tests__/methodsInstrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ test('close transaction with method result', () => {
}
});

Meteor.default_server.method_handlers.method1();
Meteor.server.method_handlers.method1();

expect(agent.currentTransaction.end.mock.calls.length).toBe(1);
expect(agent.currentTransaction.end.mock.calls[0][0]).toBe('success');

Meteor.default_server.method_handlers.method2();
Meteor.server.method_handlers.method2();

expect(agent.currentTransaction.end.mock.calls.length).toBe(2);
expect(agent.currentTransaction.end.mock.calls[1][0]).toBe('success');
Expand All @@ -51,7 +51,7 @@ test('ignore if transaction is undefined', () => {

instrumentMethods(agent, Meteor);

Meteor.default_server.method_handlers.method1();
Meteor.server.method_handlers.method1();
});

test('close transaction and its span with method result', () => {
Expand Down Expand Up @@ -79,7 +79,7 @@ test('close transaction and its span with method result', () => {
}
});

Meteor.default_server.method_handlers.method1();
Meteor.server.method_handlers.method1();

expect(agent.currentTransaction.end.mock.calls.length).toBe(1);
expect(agent.currentTransaction.end.mock.calls[0][0]).toBe('success');
Expand Down Expand Up @@ -113,14 +113,14 @@ test('catch meteor method exception', () => {
});

expect(() => {
Meteor.default_server.method_handlers.method1();
Meteor.server.method_handlers.method1();
}).toThrow();

expect(agent.captureError.mock.calls.length).toBe(1);
expect(agent.captureError.mock.calls[0][0].message).toBe('Test error 1');

expect(() => {
Meteor.default_server.method_handlers.method2();
Meteor.server.method_handlers.method2();
}).toThrow();

expect(agent.captureError.mock.calls.length).toBe(2);
Expand Down Expand Up @@ -148,7 +148,7 @@ test('transform string exception into Error object', () => {
instrumentMethods(agent, Meteor);

expect(() => {
Meteor.default_server.method_handlers.textError();
Meteor.server.method_handlers.textError();
}).toThrow();

expect(agent.captureError.mock.calls.length).toBe(1);
Expand Down
6 changes: 3 additions & 3 deletions __tests__/mocks/meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function newMeteor() {
publish: jest.fn(),
Collection,
methods(methodsMap) {
this.default_server.method_handlers = {
...this.default_server.method_handlers,
this.server.method_handlers = {
...this.server.method_handlers,
...methodsMap
};
},
default_server: {
server: {
method_handlers: {}
}
};
Expand Down
2 changes: 1 addition & 1 deletion instrumenting/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function start(agent, Meteor) {
});
}

const methodHandlers = Meteor.default_server.method_handlers;
const methodHandlers = Meteor.server.method_handlers;
Object.keys(methodHandlers).forEach(methodName => wrapMethods(methodName, methodHandlers));

shimmer.wrap(Meteor, 'methods', function(original) {
Expand Down
2 changes: 1 addition & 1 deletion meteorx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function getSession() {
headers: []
};

const server = Meteor.default_server;
const server = Meteor.server;

server._handleConnect(fakeSocket, {
msg: 'connect',
Expand Down

0 comments on commit 15b6e4c

Please sign in to comment.