Added test coverage for invalid member import emails

no issue

- This test should serve as a control for new batched importer
This commit is contained in:
Nazar Gargol 2020-08-13 22:14:52 +12:00
parent a1e6b8f898
commit ef41c57974
3 changed files with 30 additions and 0 deletions

View File

@ -57,6 +57,7 @@ const sanitizeInput = (members) => {
sanitized,
duplicateStripeCount
};
};
function serializeMemberLabels(labels) {
if (_.isString(labels)) {

View File

@ -447,6 +447,33 @@ describe('Members API', function () {
jsonResponse.meta.stats.imported.count.should.equal(0);
jsonResponse.meta.stats.invalid.count.should.equal(2);
should.equal(jsonResponse.meta.stats.invalid.errors.length, 1);
jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Missing Stripe connection');
});
});
it('Fails to import memmber with invalid values', function () {
return request
.post(localUtils.API.getApiQuery(`members/upload/`))
.attach('membersfile', path.join(__dirname, '/../../../../utils/fixtures/csv/member-invalid-email.csv'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(201)
.then((res) => {
should.not.exist(res.headers['x-cache-invalidate']);
const jsonResponse = res.body;
should.exist(jsonResponse);
should.exist(jsonResponse.meta);
should.exist(jsonResponse.meta.stats);
jsonResponse.meta.stats.imported.count.should.equal(0);
jsonResponse.meta.stats.invalid.count.should.equal(1);
should.equal(jsonResponse.meta.stats.invalid.errors.length, 1);
jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Validation (isEmail) failed for email');
});
});

View File

@ -0,0 +1,2 @@
email
invalid_email_value
1 email
2 invalid_email_value