Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix failing tests after jest upgrade #8

Merged
merged 2 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions lib/__tests__/Dynamics.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const subj = (router = new Router([Dynamics])) => {
};

describe('Dynamics', () => {
describe('on Create request', () =>
test('invokes matching callback', () =>
expect(subj().dispatch(webhookRequestOnLeadCreate)).toEqual({
describe('on Create request', () => {
test('invokes matching callback', async () =>
expect(await subj().dispatch(webhookRequestOnLeadCreate)).toEqual({
lead: 'create',
ctx: {
id: 'e837c9ec-8151-e811-a950-000d3a391928',
Expand Down Expand Up @@ -47,11 +47,12 @@ describe('Dynamics', () => {
},
},
event: webhookRequestOnLeadCreate,
})));
}));
});

describe('on Update request', () =>
test('invokes matching callback', () =>
expect(subj().dispatch(webhookRequestOnLeadUpdate)).toEqual({
describe('on Update request', () => {
test('invokes matching callback', async () =>
expect(await subj().dispatch(webhookRequestOnLeadUpdate)).toEqual({
lead: 'update',
ctx: {
id: 'e837c9ec-8151-e811-a950-000d3a391928',
Expand All @@ -64,28 +65,31 @@ describe('Dynamics', () => {
},
},
event: webhookRequestOnLeadUpdate,
})));
}));
});

describe('on Delete request', () =>
test('invokes matching callback', () =>
expect(subj().dispatch(webhookRequestOnLeadDelete)).toEqual({
describe('on Delete request', () => {
test('invokes matching callback', async () =>
expect(await subj().dispatch(webhookRequestOnLeadDelete)).toEqual({
lead: 'delete',
ctx: {
id: 'b9581547-2a60-e811-a952-000d3a391928',
entity: {},
},
event: webhookRequestOnLeadDelete,
})));
}));
});

describe('on Assign request', () =>
test('invokes matching callback', () => expect(subj().dispatch(webhookRequestOnOpportunityAssign)).toEqual({
describe('on Assign request', () => {
test('invokes matching callback', async () => expect(await subj().dispatch(webhookRequestOnOpportunityAssign)).toEqual({
opportunity: 'assign',
ctx: {
id: 'b77cca08-7450-e911-a95c-000d3a454977',
entity: {},
},
event: webhookRequestOnOpportunityAssign,
})));
}));
});

test('pluginName', () =>
expect(Dynamics.pluginName).toEqual('dynamics'));
Expand Down
22 changes: 13 additions & 9 deletions lib/__tests__/createLazyContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const webhookRequestOnLeadDelete = require('./__fixtures__/webhookRequestOnLeadD
const webhookRequestOnOpportunityAssign = require('./__fixtures__/webhookRequestOnOpportunityAssign');


const subj = payload => createLazyContext(payload);
const subj = (payload) => createLazyContext(payload);

describe('createLazyContext', () => {
describe('on Create request', () =>
describe('on Create request', () => {
test('extracts entity and id', () =>
expect(subj(webhookRequestOnLeadCreate.body)).toMatchObject({
id: 'e837c9ec-8151-e811-a950-000d3a391928',
Expand All @@ -35,9 +35,10 @@ describe('createLazyContext', () => {
subject: 'Hello there!',
yomifullname: 'Max Mustermann',
},
})));
}));
});

describe('on Update request', () =>
describe('on Update request', () => {
test('extracts entity', () =>
expect(subj(webhookRequestOnLeadUpdate.body)).toMatchObject({
id: 'e837c9ec-8151-e811-a950-000d3a391928',
Expand All @@ -48,19 +49,22 @@ describe('createLazyContext', () => {
modifiedon: '2018-05-06T23:05:11.000Z',
modifiedonbehalfby: null,
},
})));
}));
});

describe('on Assign request', () =>
describe('on Assign request', () => {
test('extracts entity', () =>
expect(subj(webhookRequestOnOpportunityAssign.body)).toMatchObject({
id: 'b77cca08-7450-e911-a95c-000d3a454977',
entity: {},
})));
}));
});

describe('on Delete request', () =>
describe('on Delete request', () => {
test('extracts entity', () =>
expect(subj(webhookRequestOnLeadDelete.body)).toMatchObject({
id: 'b9581547-2a60-e811-a952-000d3a391928',
entity: {},
})));
}));
});
});
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@everestate/serverless-router-dynamics",
"version": "0.4.0",
"version": "0.4.1",
"description": "Serverless Router plugin to handle Microsoft Dynamics Webhooks",
"keywords": [
"serverless",
Expand Down Expand Up @@ -36,10 +36,10 @@
"@everestate/serverless-router": ">=0.4.0"
},
"devDependencies": {
"eslint": "^5.12.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jest": "^22.1.3",
"jest": "^23.6.0"
"eslint": "^6.2.2",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.15.2",
"jest": "^24.9.0"
}
}
Loading