Skip to content

Instantly share code, notes, and snippets.

@mycatnamedweb
Created July 7, 2015 23:49
Show Gist options
  • Save mycatnamedweb/7a9e464836449c07bd39 to your computer and use it in GitHub Desktop.
Save mycatnamedweb/7a9e464836449c07bd39 to your computer and use it in GitHub Desktop.
var chai = require('chai');
var expect = chai.expect;
var sinon = require('sinon');
chai.use(require('sinon-chai'));
var server = require('../server');
describe('uppercase-fiscalcode', () => {
var s;
beforeEach(() => {
s = sinon.sandbox.create();
s.spy(server, 'request');
});
afterEach(() => {
s.restore();
});
it('should alter the fiscalcode to uppercase', () => {
var testFiscalCode = 'sccgpl89l05m052m';
var reqPayload = {
method: 'POST',
uri: '/api/registration',
json: {
fiscalCode: testFiscalCode.toUppercase(),
userName: "secchigianpa",
password: "s3cch1",
firstName: "Gianpaolo",
lastName: "Secchi",
gender: "M",
email: "g.secchi8@gmail.com",
dateOfBirth: "05/07/1989",
placeOfBirth: 'M052M',
depositLimit: '800',
provinceOfBirth: 'MB',
provinceOfResidence: 'UD',
termsAndConditionsAgreed: true,
registrationQuestionAndAnswer: {
question: 'Cat name',
answer: 'Dumb'
}
},
};
server.request(reqPayload);
expect(server.request).to.be.calledOnce;
expect(server.request.firstCall.args[0].json.fiscalcode).to.equal("SCCGPL89L05M052M");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment