feat: add integration tests for deleteRecordById method. fix: add toJSON method on SaveRecordRequest model to handle converting fields map to a POJO before sending in request

This commit is contained in:
StevanFreeborn
2023-02-19 15:53:52 -06:00
parent 818bd0dd19
commit 99c7e7f9f1
6 changed files with 164 additions and 3 deletions
+50
View File
@@ -54,4 +54,54 @@ describe('SaveRecordRequest', function () {
expect(saveRecordRequest.fields).to.not.be.null.and.not.be.undefined;
expect(saveRecordRequest.fields).to.have.lengthOf(2);
});
describe('toJSON', function () {
it('should be defined', function () {
expect(SaveRecordRequest.prototype.toJSON).to.not.be.undefined;
});
it('should return an object', function () {
expect(new SaveRecordRequest(1).toJSON()).to.be.an('object');
});
it('should return an object with an appId property', function () {
expect(new SaveRecordRequest(1).toJSON()).to.have.property('appId');
});
it('should return an object with a recordId property', function () {
expect(new SaveRecordRequest(1).toJSON()).to.have.property('recordId');
});
it('should return an object with a fields property', function () {
expect(new SaveRecordRequest(1).toJSON()).to.have.property('fields');
});
it('should return an object with an appId property that is equal to the value of the appId property', function () {
expect(new SaveRecordRequest(1).toJSON()).to.have.property('appId', 1);
});
it('should return an object with a recordId property that is equal to the value of the recordId property', function () {
expect(new SaveRecordRequest(1, 2).toJSON()).to.have.property(
'recordId',
2
);
});
it('should return an object with a fields property that is equal to the value of the fields property', function () {
const map = new Map([
[1, 'test'],
[2, 'test'],
]);
const obj = {
1: 'test',
2: 'test',
};
const saveRecordRequest = new SaveRecordRequest(1, 2, map);
const json = saveRecordRequest.toJSON();
expect(json.fields).to.deep.equal(obj);
});
});
});