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

Fix bug in assertions returning true for some tests #100

Merged
merged 31 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ee1833c
Fix assertion for account test
galadim1 Apr 5, 2024
91c37d9
Fix assertion for contact test
galadim1 Apr 5, 2024
750e72c
add more custom attribute assertion
galadim1 Apr 5, 2024
59dd08c
Fix assertion bug for customer-note test
galadim1 Apr 5, 2024
95ab42f
Fix assertions for customer
galadim1 Apr 5, 2024
c0dab2a
Fxi assertion for invoices
galadim1 Apr 5, 2024
832287c
Fix assertion for ping
galadim1 Apr 5, 2024
657159c
Fix assertion for plan group
galadim1 Apr 5, 2024
b5c2d20
Fix assertion in plan
galadim1 Apr 5, 2024
6f69c5b
fix assertion for subscription test
galadim1 Apr 5, 2024
b15fb21
Fix seertion for subscription events
galadim1 Apr 5, 2024
088e51e
Fix resource assertion
galadim1 Apr 5, 2024
99bb967
fix resource
galadim1 Apr 5, 2024
3c5d2d8
Fix incorrect assertion for customer
galadim1 Apr 8, 2024
095f2d0
Update version
galadim1 Apr 8, 2024
096194d
Update version
galadim1 Apr 8, 2024
3f28a66
Merge branch 'Fix-bug-in-assertions-returning-true-for-some-tests' of…
galadim1 Apr 8, 2024
34e6659
Merge branch 'Fix-bug-in-assertions-returning-true-for-some-tests' of…
galadim1 Apr 8, 2024
5671fa9
Merge branch 'Fix-bug-in-assertions-returning-true-for-some-tests' of…
galadim1 Apr 8, 2024
ede0cd7
update version
galadim1 Apr 8, 2024
0c36c41
Fix incorrect assertion for customer
galadim1 Apr 8, 2024
d702403
Merge branch 'Fix-bug-in-assertions-returning-true-for-some-tests' of…
galadim1 Apr 8, 2024
f78c24a
Merge branch 'Fix-bug-in-assertions-returning-true-for-some-tests' of…
galadim1 Apr 8, 2024
78aa23c
Merge branch 'Fix-bug-in-assertions-returning-true-for-some-tests' of…
galadim1 Apr 8, 2024
bf0481f
Update package.json formatting
galadim1 Apr 8, 2024
d6385e6
revert formatting package.json
galadim1 Apr 8, 2024
fe937b4
add change log
galadim1 Apr 8, 2024
162b987
revert package.json
galadim1 Apr 8, 2024
82df5df
change version
galadim1 Apr 8, 2024
a6801ff
change intention
galadim1 Apr 8, 2024
501f140
change version
galadim1 Apr 8, 2024
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
102 changes: 51 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
{
"name": "chartmogul-node",
"version": "3.4.0",
"description": "Official Chartmogul API Node.js Client",
"main": "lib/chartmogul.js",
"scripts": {
"test": "mocha",
"lint": "eslint --fix .",
"cover": "nyc mocha",
"prepare": "npm run lint && npm run test"
},
"repository": {
"type": "git",
"url": "https://github.com/chartmogul/chartmogul-node.git"
},
"keywords": [
"chartmogul",
"api"
],
"author": "ChartMogul Ltd. <[email protected]>",
"contributors": [
"Mahmudul Hassan <[email protected]>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/chartmogul/chartmogul-node/issues"
},
"homepage": "https://github.com/chartmogul/chartmogul-node",
"engines": {
"node": ">=16"
},
"dependencies": {
"retry": "^0.13.1",
"superagent": "^8.1.2",
"uri-templates": "^0.2.0"
},
"devDependencies": {
"@babel/traverse": ">=7.23.2",
"chai": "",
"dependency-lint": "^7.1.0",
"eslint": "^8.54.0",
"eslint-config-standard": "",
"eslint-plugin-import": "",
"eslint-plugin-n": "",
"eslint-plugin-promise": "",
"eslint-plugin-standard": "",
"mocha": "",
"nock": "",
"nyc": "^15.1.0",
"pre-commit": ""
},
"pre-commit": "prepare"
"name": "chartmogul-node",
galadim1 marked this conversation as resolved.
Show resolved Hide resolved
"version": "3.5.0",
"description": "Official Chartmogul API Node.js Client",
"main": "lib/chartmogul.js",
"scripts": {
"test": "mocha",
"lint": "eslint --fix .",
"cover": "nyc mocha",
"prepare": "npm run lint && npm run test"
},
"repository": {
"type": "git",
"url": "https://github.com/chartmogul/chartmogul-node.git"
},
"keywords": [
"chartmogul",
"api"
],
"author": "ChartMogul Ltd. <[email protected]>",
"contributors": [
"Mahmudul Hassan <[email protected]>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/chartmogul/chartmogul-node/issues"
},
"homepage": "https://github.com/chartmogul/chartmogul-node",
"engines": {
"node": ">=16"
},
"dependencies": {
"retry": "^0.13.1",
"superagent": "^8.1.2",
"uri-templates": "^0.2.0"
},
"devDependencies": {
"@babel/traverse": ">=7.23.2",
"chai": "",
"dependency-lint": "^7.1.0",
"eslint": "^8.54.0",
"eslint-config-standard": "",
"eslint-plugin-import": "",
"eslint-plugin-n": "",
"eslint-plugin-promise": "",
"eslint-plugin-standard": "",
"mocha": "",
"nock": "",
"nyc": "^15.1.0",
"pre-commit": ""
},
"pre-commit": "prepare"
}
20 changes: 8 additions & 12 deletions test/chartmogul/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@ const nock = require('nock');
const Account = ChartMogul.Account;

describe('Account', () => {
it('should retrieve the details of current account', () => {
it('should retrieve the details of current account', async () => {
nock(config.API_BASE)
.get('/v1/account')
.reply(200, {
/* eslint-disable camelcase */
/* eslint-disable camelcase */
name: 'Example Test Company',
currency: 'EUR',
time_zone: 'Europe/Berlin',
week_start_on: 'sunday'
/* eslint-enable camelcase */
/* eslint-enable camelcase */
});

return Account.retrieve(config, (err, res) => {
if (err) {
return err;
}
expect(res.name).to.be.equal('Example Test Company');
expect(res.currency).to.be.equal('EUR');
expect(res.time_zone).to.be.equal('Europe/Berlin');
expect(res.week_start_on).to.be.equal('sunday');
});
const account = await Account.retrieve(config);
expect(account.name).to.be.equal('Example Test Company');
expect(account.currency).to.be.equal('EUR');
expect(account.time_zone).to.be.equal('Europe/Berlin');
expect(account.week_start_on).to.be.equal('sunday');
});
});
73 changes: 33 additions & 40 deletions test/chartmogul/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const nock = require('nock');
const Contact = ChartMogul.Contact;

describe('Contact', () => {
it('creates a new contact', () => {
it('creates a new contact', async () => {
const postBody = {
/* eslint-disable camelcase */
customer_uuid: 'cus_919d5d7c-9e23-11ed-a936-97fbf69ba02b',
Expand Down Expand Up @@ -53,13 +53,11 @@ describe('Contact', () => {
/* eslint-enable camelcase */
});

Contact.create(config, postBody)
.then(res => {
expect(res).to.have.property('uuid');
});
const contact = await Contact.create(config, postBody);
expect(contact).to.have.property('uuid');
});

it('should list all contacts with pagination', done => {
it('should list all contacts with pagination', async () => {
const query = {
per_page: 1,
cursor: 'cursor=='
Expand All @@ -82,36 +80,34 @@ describe('Contact', () => {
/* eslint-enable camelcase */
});

Contact.all(config, query)
.then(res => {
expect(res).to.have.property('entries');
expect(res.entries).to.be.instanceof(Array);
expect(res.cursor).to.eql('MjAyMy0wMy0xM1QxMjowMTozMi44MD==');
expect(res.has_more).to.eql(false);
});
done();
const contact = await Contact.all(config, query);
expect(contact).to.have.property('entries');
expect(contact).to.have.property('cursor');
expect(contact).to.have.property('has_more');
expect(contact.entries).to.be.instanceof(Array);
expect(contact.cursor).to.eql('MjAyMy0wMy0xM1QxMjowMTozMi44MD==');
expect(contact.has_more).to.eql(false);
});

it('throws DeprecatedParamError if using old pagination parameter', done => {
const query = {
page: 1
};
it('throws DeprecatedParamError if using old pagination parameter', async () => {
const query = { page: 1 };

nock(config.API_BASE)
.get('/v1/contacts')
.query(query)
.reply(200, {});
Contact.all(config, query)
.then(res => done(new Error('Should throw error')))

await Contact.all(config, query)
.catch(e => {
expect(e).to.be.instanceOf(ChartMogul.DeprecatedParamError);
expect(e.httpStatus).to.equal(422);
expect(e.message).to.equal('"page" param is deprecated {}');
expect(e.httpStatus).to.equal(422);
// eslint-disable-next-line no-unused-expressions
expect(e.response).to.empty;
});
done();
});

it('retrieves a contact', () => {
it('retrieves a contact', async () => {
const contactUuid = 'con_00000000-0000-0000-0000-000000000000';

nock(config.API_BASE)
Expand All @@ -138,13 +134,11 @@ describe('Contact', () => {
/* eslint-enable camelcase */
});

return Contact.retrieve(config, contactUuid)
.then(res => {
expect(res).to.have.property('uuid');
});
const contact = await Contact.retrieve(config, contactUuid);
expect(contact).to.have.property('uuid');
});

it('updates a contact', () => {
it('updates a contact', async () => {
const contactUuid = 'con_00000000-0000-0000-0000-000000000000';

/* eslint-disable camelcase */
Expand All @@ -163,34 +157,33 @@ describe('Contact', () => {
/* eslint-enable camelcase */
});

return Contact.modify(config, contactUuid, postBody)
.then(res => {
expect(res.email).to.be.equal('[email protected]');
});
const contact = await Contact.modify(config, contactUuid, postBody);
expect(contact.email).to.be.equal('[email protected]');
});

it('deletes a contact', () => {
it('deletes a contact', async () => {
const uuid = 'con_00000000-0000-0000-0000-000000000000';

nock(config.API_BASE)
.delete('/v1/contacts' + '/' + uuid)
.reply(204);

return Contact.destroy(config, uuid);
const contact = await Contact.destroy(config, uuid);
// eslint-disable-next-line no-unused-expressions
expect(contact).to.be.empty;
});

it('merges contacts', () => {
it('merges contacts', async () => {
const intoUuid = 'con_00000000-0000-0000-0000-000000000000';
const fromUuid = 'con_00000000-0000-0000-0000-000000000001';

nock(config.API_BASE)
.post(`/v1/contacts/${intoUuid}/merge/${fromUuid}`)
.reply(200, {});

return Contact.merge(config, intoUuid, fromUuid)
.then(res => {
expect(200);
expect(res).to.be.instanceof(Object);
});
const result = await Contact.merge(config, intoUuid, fromUuid);
// eslint-disable-next-line no-unused-expressions
expect(result).to.empty;
expect(result).to.be.instanceof(Object);
});
});
2 changes: 2 additions & 0 deletions test/chartmogul/custom-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ describe('CustomAttribute', () => {
return CustomAttribute.add(config, customerUuid, postBody)
.then(res => {
expect(res).to.have.property('custom');
expect(res.custom.channel).to.be.equal('Facebook');
expect(res.custom.age).to.be.equal(8);
});
});

Expand Down
24 changes: 13 additions & 11 deletions test/chartmogul/customer-note.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ describe('CustomerNote', () => {
author: 'John Doe ([email protected])'
});

CustomerNote.create(config, postBody)
return CustomerNote.create(config, postBody)
.then(res => {
expect(res.customer_uuid).to.be.equal(uuid);
expect(res.text).to.be.equal('This is a note');
});
});

it('lists all notes from a customer', () => {
it('lists all notes from a customer', async () => {
const uuid = 'cus_00000000-0000-0000-0000-000000000000';
const body = { customer_uuid: uuid, per_page: 10, cursor: 'cursor==' };

nock(config.API_BASE)
.get('/v1/customer_notes')
.get(`/v1/customer_notes?customer_uuid=${uuid}&per_page=10&cursor=cursor==`)
.reply(200, {
entries: [{
uuid: 'note_00000000-0000-0000-0000-000000000000',
Expand All @@ -51,10 +52,9 @@ describe('CustomerNote', () => {
}]
});

CustomerNote.all(config, uuid)
.then(res => {
expect(res.entries).to.haveLength(1);
});
const customerNote = await CustomerNote.all(config, body);
expect(customerNote.entries).to.have.lengthOf(1);
expect(customerNote.entries[0].customer_uuid).to.equal(uuid);
});

it('retrieves a customer note', () => {
Expand All @@ -72,8 +72,9 @@ describe('CustomerNote', () => {
author: 'John Doe ([email protected])'
});

CustomerNote.retrieve(config, uuid).then(res => {
return CustomerNote.retrieve(config, uuid).then(res => {
expect(res).to.have.property('uuid');
expect(res.uuid).to.equal(uuid);
});
});

Expand All @@ -97,7 +98,7 @@ describe('CustomerNote', () => {
/* eslint-enable camelcase */
});

CustomerNote.patch(config, uuid, postBody)
return CustomerNote.patch(config, uuid, postBody)
.then(res => {
expect(res.text).to.be.equal('This is a note');
});
Expand All @@ -110,9 +111,10 @@ describe('CustomerNote', () => {
.delete(`/v1/customer_notes/${uuid}`)
.reply(204);

CustomerNote.destroy(config, uuid)
return CustomerNote.destroy(config, uuid)
.then(res => {
expect(res).to.be.equal({});
// eslint-disable-next-line no-unused-expressions
expect(res).to.be.empty;
});
});
});
Loading
Loading