fix: refactor to have child classes that inherit from RecordValue, but represent the distinct types of value objects that can be returned by the api. fix: added and updated tests to address this refactor
This commit is contained in:
+520
-42
@@ -15,9 +15,6 @@ import { ReferenceField } from '../src/models/ReferenceField';
|
||||
import { Multiplicity } from '../src/enums/Multiplicity';
|
||||
import { ListField } from '../src/models/ListField';
|
||||
import { File } from '../src/models/File';
|
||||
import fs from 'fs';
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import path from 'path';
|
||||
import { ListItemResponse } from '../src/models/ListItemResponse';
|
||||
import { GetPagedReportsResponse } from '../src/models/GetPagedReportsResponse';
|
||||
import { Report } from '../src/models/Report';
|
||||
@@ -26,6 +23,10 @@ import { Row } from '../src/models/Row';
|
||||
import { Record } from '../src/models/Record';
|
||||
import { RecordValue } from '../src/models/RecordValue';
|
||||
import { GetPagedRecordsResponse } from '../src/models/GetPagedRecordsResponse';
|
||||
import { testFieldData } from './testData/testFieldData';
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
describe('ApiResponse', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -1142,36 +1143,172 @@ describe('ApiResponse', function () {
|
||||
});
|
||||
|
||||
it('should return an ApiResponse<Record>', function () {
|
||||
testFieldData.forEach((recordValue) => {
|
||||
const mockResponseData = {
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [recordValue],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
const record = apiResponse.asRecordType();
|
||||
|
||||
expect(record).to.be.an.instanceof(ApiResponse<Record>);
|
||||
expect(record.data).to.be.an.instanceof(Record);
|
||||
expect(record.data).to.have.property('appId', 1);
|
||||
expect(record.data).to.have.property('recordId', 1);
|
||||
expect(record.data).to.have.property('fieldData').that.is.an('array');
|
||||
expect(record.data).to.not.be.null;
|
||||
|
||||
if (record.data != null) {
|
||||
record.data.fieldData.forEach((recordValue) => {
|
||||
expect(recordValue).to.be.an.instanceof(RecordValue);
|
||||
expect(recordValue).to.have.property('type');
|
||||
expect(recordValue).to.have.property('fieldId');
|
||||
expect(recordValue).to.have.property('value');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error if a record value contains an unknown type', function () {
|
||||
const mockResponseData = {
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Text',
|
||||
fieldId: 'field 1',
|
||||
value: 'field value 1',
|
||||
type: 'Unknown',
|
||||
fieldId: 1,
|
||||
value: 'value',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
const record = apiResponse.asRecordType();
|
||||
|
||||
expect(record).to.be.an.instanceof(ApiResponse<Record>);
|
||||
expect(record.data).to.be.an.instanceof(Record);
|
||||
expect(record.data).to.have.property('appId', 1);
|
||||
expect(record.data).to.have.property('recordId', 1);
|
||||
expect(record.data).to.have.property('fieldData').that.is.an('array');
|
||||
expect(record.data).to.not.be.null;
|
||||
expect(() => {
|
||||
apiResponse.asRecordType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
if (record.data != null) {
|
||||
record.data.fieldData.forEach((recordValue) => {
|
||||
expect(recordValue).to.be.an.instanceof(RecordValue);
|
||||
expect(recordValue).to.have.property('type');
|
||||
expect(recordValue).to.have.property('fieldId');
|
||||
expect(recordValue).to.have.property('value');
|
||||
});
|
||||
}
|
||||
it('should throw an error if a record value for a survey delegate field contains an unknown delegate type', function () {
|
||||
const mockResponseData = {
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'ScoringGroupList',
|
||||
fieldId: 12167,
|
||||
value: [
|
||||
{
|
||||
delegateType: 'Unknown',
|
||||
name: 'test_delegate',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationType: 'AllPages',
|
||||
pageIds: [],
|
||||
answeredPageIds: [],
|
||||
canReadOtherPages: false,
|
||||
delegationDateTime: '2023-01-17T05:52:53.781Z',
|
||||
delegationCompletedDateTime: '2023-01-17T05:53:12.617Z',
|
||||
status: 'Pending',
|
||||
isDeleted: false,
|
||||
messagingDisplayText:
|
||||
'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM',
|
||||
guid: '00000000-0000-0000-0000-000000000000',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for an attachment field contains an unknown file storage site type', function () {
|
||||
const mockResponseData = {
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'AttachmentList',
|
||||
fieldId: 12888,
|
||||
value: [
|
||||
{
|
||||
fileId: 1348,
|
||||
fileName: 'onspring-api-playground.py',
|
||||
notes: '',
|
||||
storageLocation: 'Unknown',
|
||||
},
|
||||
{
|
||||
fileId: 1349,
|
||||
fileName: 'core_isolation_warning.png',
|
||||
notes: '',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for a timespan field contains an unknown increment type', function () {
|
||||
const mockResponseData = {
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Unknown',
|
||||
recurrence: 'EndByDate',
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for a timespan field contains an unknown recurrence type', function () {
|
||||
const mockResponseData = {
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Days',
|
||||
recurrence: 'Unknown',
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordType();
|
||||
}).to.throw();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1203,24 +1340,12 @@ describe('ApiResponse', function () {
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Text',
|
||||
fieldId: 'field 1',
|
||||
value: 'field value 1',
|
||||
},
|
||||
],
|
||||
fieldData: testFieldData,
|
||||
},
|
||||
{
|
||||
appId: 2,
|
||||
recordId: 2,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Text',
|
||||
fieldId: 'field 1',
|
||||
value: 'field value 1',
|
||||
},
|
||||
],
|
||||
fieldData: testFieldData,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1250,9 +1375,203 @@ describe('ApiResponse', function () {
|
||||
if (getPagedRecordsResponse.data != null) {
|
||||
getPagedRecordsResponse.data.items.forEach((record) => {
|
||||
expect(record).to.be.an.instanceof(Record);
|
||||
|
||||
expect(record).to.have.property('appId');
|
||||
expect(record).to.have.property('recordId');
|
||||
expect(record).to.have.property('fieldData').that.is.an('array');
|
||||
expect(record).to.not.be.null;
|
||||
|
||||
if (record != null) {
|
||||
record.fieldData.forEach((recordValue) => {
|
||||
expect(recordValue).to.be.an.instanceof(RecordValue);
|
||||
expect(recordValue).to.have.property('type');
|
||||
expect(recordValue).to.have.property('fieldId');
|
||||
expect(recordValue).to.have.property('value');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error if a record value contains an unknown type', function () {
|
||||
const mockResponseData = {
|
||||
pageSize: 1,
|
||||
pageNumber: 1,
|
||||
totalRecords: 1,
|
||||
totalPages: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Unknown',
|
||||
fieldId: 1,
|
||||
value: 'value',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asGetPagedRecordsResponseType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if a record value for a survey delegate field contains an unknown delegate type', function () {
|
||||
const mockResponseData = {
|
||||
pageSize: 1,
|
||||
pageNumber: 1,
|
||||
totalRecords: 1,
|
||||
totalPages: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'ScoringGroupList',
|
||||
fieldId: 12167,
|
||||
value: [
|
||||
{
|
||||
delegateType: 'Unknown',
|
||||
name: 'test_delegate',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationType: 'AllPages',
|
||||
pageIds: [],
|
||||
answeredPageIds: [],
|
||||
canReadOtherPages: false,
|
||||
delegationDateTime: '2023-01-17T05:52:53.781Z',
|
||||
delegationCompletedDateTime: '2023-01-17T05:53:12.617Z',
|
||||
status: 'Pending',
|
||||
isDeleted: false,
|
||||
messagingDisplayText:
|
||||
'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM',
|
||||
guid: '00000000-0000-0000-0000-000000000000',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asGetPagedRecordsResponseType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for an attachment field contains an unknown file storage site type', function () {
|
||||
const mockResponseData = {
|
||||
pageSize: 1,
|
||||
pageNumber: 1,
|
||||
totalRecords: 1,
|
||||
totalPages: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'AttachmentList',
|
||||
fieldId: 12888,
|
||||
value: [
|
||||
{
|
||||
fileId: 1348,
|
||||
fileName: 'onspring-api-playground.py',
|
||||
notes: '',
|
||||
storageLocation: 'Unknown',
|
||||
},
|
||||
{
|
||||
fileId: 1349,
|
||||
fileName: 'core_isolation_warning.png',
|
||||
notes: '',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asGetPagedRecordsResponseType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for a timespan field contains an unknown increment type', function () {
|
||||
const mockResponseData = {
|
||||
pageSize: 1,
|
||||
pageNumber: 1,
|
||||
totalRecords: 1,
|
||||
totalPages: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Unknown',
|
||||
recurrence: 'EndByDate',
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asGetPagedRecordsResponseType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for a timespan field contains an unknown recurrence type', function () {
|
||||
const mockResponseData = {
|
||||
pageSize: 1,
|
||||
pageNumber: 1,
|
||||
totalRecords: 1,
|
||||
totalPages: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Days',
|
||||
recurrence: 'Unknown',
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asGetPagedRecordsResponseType();
|
||||
}).to.throw();
|
||||
});
|
||||
});
|
||||
|
||||
describe('asRecordCollectionType', function () {
|
||||
@@ -1275,13 +1594,7 @@ describe('ApiResponse', function () {
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Text',
|
||||
fieldId: 'field 1',
|
||||
value: 'field value 1',
|
||||
},
|
||||
],
|
||||
fieldData: testFieldData,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1322,5 +1635,170 @@ describe('ApiResponse', function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error if a record value contains an unknown type', function () {
|
||||
const mockResponseData = {
|
||||
count: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Unknown',
|
||||
fieldId: 1,
|
||||
value: 'value',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordCollectionType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if a record value for a survey delegate field contains an unknown delegate type', function () {
|
||||
const mockResponseData = {
|
||||
count: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'ScoringGroupList',
|
||||
fieldId: 12167,
|
||||
value: [
|
||||
{
|
||||
delegateType: 'Unknown',
|
||||
name: 'test_delegate',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationType: 'AllPages',
|
||||
pageIds: [],
|
||||
answeredPageIds: [],
|
||||
canReadOtherPages: false,
|
||||
delegationDateTime: '2023-01-17T05:52:53.781Z',
|
||||
delegationCompletedDateTime: '2023-01-17T05:53:12.617Z',
|
||||
status: 'Pending',
|
||||
isDeleted: false,
|
||||
messagingDisplayText:
|
||||
'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM',
|
||||
guid: '00000000-0000-0000-0000-000000000000',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordCollectionType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for an attachment field contains an unknown file storage site type', function () {
|
||||
const mockResponseData = {
|
||||
count: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'AttachmentList',
|
||||
fieldId: 12888,
|
||||
value: [
|
||||
{
|
||||
fileId: 1348,
|
||||
fileName: 'onspring-api-playground.py',
|
||||
notes: '',
|
||||
storageLocation: 'Unknown',
|
||||
},
|
||||
{
|
||||
fileId: 1349,
|
||||
fileName: 'core_isolation_warning.png',
|
||||
notes: '',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordCollectionType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for a timespan field contains an unknown increment type', function () {
|
||||
const mockResponseData = {
|
||||
count: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Unknown',
|
||||
recurrence: 'EndByDate',
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordCollectionType();
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if record value for a timespan field contains an unknown recurrence type', function () {
|
||||
const mockResponseData = {
|
||||
count: 1,
|
||||
items: [
|
||||
{
|
||||
appId: 1,
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Days',
|
||||
recurrence: 'Unknown',
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const apiResponse = new ApiResponse(200, 'OK', mockResponseData);
|
||||
|
||||
expect(() => {
|
||||
apiResponse.asRecordCollectionType();
|
||||
}).to.throw();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { AttachmentListRecordValue } from '../src/models/AttachmentListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('AttachmentListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(AttachmentListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(AttachmentListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(AttachmentListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const attachmentListRecordValue = new AttachmentListRecordValue(1, []);
|
||||
expect(attachmentListRecordValue).to.have.property('fieldId');
|
||||
expect(attachmentListRecordValue).to.have.property('value');
|
||||
expect(attachmentListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const attachmentListRecordValue = new AttachmentListRecordValue(1, []);
|
||||
expect(attachmentListRecordValue.fieldId).to.equal(1);
|
||||
expect(attachmentListRecordValue.value).to.deep.equal([]);
|
||||
expect(attachmentListRecordValue.type).to.equal('AttachmentList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import { DateRecordValue } from '../src/models/DateRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('DateRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(DateRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(DateRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(DateRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const dateRecordValue = new DateRecordValue(1, new Date());
|
||||
expect(dateRecordValue).to.have.property('fieldId');
|
||||
expect(dateRecordValue).to.have.property('value');
|
||||
expect(dateRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const date = new Date();
|
||||
const dateRecordValue = new DateRecordValue(1, date);
|
||||
expect(dateRecordValue.fieldId).to.equal(1);
|
||||
expect(dateRecordValue.value).to.deep.equal(date);
|
||||
expect(dateRecordValue.type).to.equal('Date');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { DecimalRecordValue } from '../src/models/DecimalRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('DecimalRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(DecimalRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(DecimalRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(DecimalRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const decimalRecordValue = new DecimalRecordValue(1, 1);
|
||||
expect(decimalRecordValue).to.have.property('fieldId');
|
||||
expect(decimalRecordValue).to.have.property('value');
|
||||
expect(decimalRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const decimalRecordValue = new DecimalRecordValue(1, 1);
|
||||
expect(decimalRecordValue.fieldId).to.equal(1);
|
||||
expect(decimalRecordValue.value).to.deep.equal(1);
|
||||
expect(decimalRecordValue.type).to.equal('Decimal');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { DelegateListRecordValue } from '../src/models/DelegateListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('DelegateListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(DelegateListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(DelegateListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(DelegateListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const delegateListRecordValue = new DelegateListRecordValue(1, []);
|
||||
expect(delegateListRecordValue).to.have.property('fieldId');
|
||||
expect(delegateListRecordValue).to.have.property('value');
|
||||
expect(delegateListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const delegateListRecordValue = new DelegateListRecordValue(1, []);
|
||||
expect(delegateListRecordValue.fieldId).to.equal(1);
|
||||
expect(delegateListRecordValue.value).to.deep.equal([]);
|
||||
expect(delegateListRecordValue.type).to.equal('DelegateList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { FileListRecordValue } from '../src/models/FileListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('FileListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(FileListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(FileListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(FileListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const fileListRecordValue = new FileListRecordValue(1, []);
|
||||
expect(fileListRecordValue).to.have.property('fieldId');
|
||||
expect(fileListRecordValue).to.have.property('value');
|
||||
expect(fileListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const fileListRecordValue = new FileListRecordValue(1, []);
|
||||
expect(fileListRecordValue.fieldId).to.equal(1);
|
||||
expect(fileListRecordValue.value).to.deep.equal([]);
|
||||
expect(fileListRecordValue.type).to.equal('FileList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { GuidListRecordValue } from '../src/models/GuidListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('GuidListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(GuidListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(GuidListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(GuidListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const guidListRecordValue = new GuidListRecordValue(1, []);
|
||||
expect(guidListRecordValue).to.have.property('fieldId');
|
||||
expect(guidListRecordValue).to.have.property('value');
|
||||
expect(guidListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const guidListRecordValue = new GuidListRecordValue(1, []);
|
||||
expect(guidListRecordValue.fieldId).to.equal(1);
|
||||
expect(guidListRecordValue.value).to.deep.equal([]);
|
||||
expect(guidListRecordValue.type).to.equal('GuidList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { GuidRecordValue } from '../src/models/GuidRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('GuidRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(GuidRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(GuidRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(GuidRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const guidRecordValue = new GuidRecordValue(1, 'test');
|
||||
expect(guidRecordValue).to.have.property('fieldId');
|
||||
expect(guidRecordValue).to.have.property('value');
|
||||
expect(guidRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const guidRecordValue = new GuidRecordValue(1, 'test');
|
||||
expect(guidRecordValue.fieldId).to.equal(1);
|
||||
expect(guidRecordValue.value).to.deep.equal('test');
|
||||
expect(guidRecordValue.type).to.equal('Guid');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { IntegerListRecordValue } from '../src/models/IntegerListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('IntegerListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(IntegerListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(IntegerListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(IntegerListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const integerListRecordValue = new IntegerListRecordValue(1, []);
|
||||
expect(integerListRecordValue).to.have.property('fieldId');
|
||||
expect(integerListRecordValue).to.have.property('value');
|
||||
expect(integerListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const integerListRecordValue = new IntegerListRecordValue(1, []);
|
||||
expect(integerListRecordValue.fieldId).to.equal(1);
|
||||
expect(integerListRecordValue.value).to.deep.equal([]);
|
||||
expect(integerListRecordValue.type).to.equal('IntegerList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { IntegerRecordValue } from '../src/models/IntegerRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('IntegerRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(IntegerRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(IntegerRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(IntegerRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const integerRecordValue = new IntegerRecordValue(1, 1);
|
||||
expect(integerRecordValue).to.have.property('fieldId');
|
||||
expect(integerRecordValue).to.have.property('value');
|
||||
expect(integerRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const integerRecordValue = new IntegerRecordValue(1, 1);
|
||||
expect(integerRecordValue.fieldId).to.equal(1);
|
||||
expect(integerRecordValue.value).to.deep.equal(1);
|
||||
expect(integerRecordValue.type).to.equal('Integer');
|
||||
});
|
||||
});
|
||||
@@ -2867,12 +2867,12 @@ describe('OnspringClient', function () {
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Text',
|
||||
type: 'String',
|
||||
fieldId: 1,
|
||||
value: 'Test',
|
||||
},
|
||||
{
|
||||
type: 'Text',
|
||||
type: 'String',
|
||||
fieldId: 2,
|
||||
value: 'Test',
|
||||
},
|
||||
@@ -3047,12 +3047,12 @@ describe('OnspringClient', function () {
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'Text',
|
||||
type: 'String',
|
||||
fieldId: 1,
|
||||
value: 'Test',
|
||||
},
|
||||
{
|
||||
type: 'Text',
|
||||
type: 'String',
|
||||
fieldId: 2,
|
||||
value: 'Test',
|
||||
},
|
||||
@@ -3250,12 +3250,12 @@ describe('OnspringClient', function () {
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'text',
|
||||
type: 'String',
|
||||
fieldId: 1,
|
||||
value: 'Test',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
type: 'String',
|
||||
fieldId: 2,
|
||||
value: 'Test',
|
||||
},
|
||||
@@ -3450,12 +3450,12 @@ describe('OnspringClient', function () {
|
||||
recordId: 1,
|
||||
fieldData: [
|
||||
{
|
||||
type: 'text',
|
||||
type: 'String',
|
||||
fieldId: 1,
|
||||
value: 'value',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
type: 'String',
|
||||
fieldId: 2,
|
||||
value: 'value',
|
||||
},
|
||||
|
||||
+47
-132
@@ -5,6 +5,10 @@ import { Attachment } from '../src/models/Attachment';
|
||||
import { Delegate } from '../src/models/Delegate';
|
||||
import { ScoringGroup } from '../src/models/ScoringGroup';
|
||||
import { TimeSpanData } from '../src/models/TimeSpanData';
|
||||
import { FileStorageSite } from '../src/enums/FileStorageSite';
|
||||
import { DelegateType } from '../src/enums/DelegateType';
|
||||
import { TimeSpanRecurrenceType } from '../src/enums/TimeSpanRecurrenceType';
|
||||
import { TimeSpanIncrement } from '../src/enums/TimeSpanIncrement';
|
||||
|
||||
describe('RecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -112,9 +116,9 @@ describe('RecordValue', function () {
|
||||
});
|
||||
|
||||
it('should return the value as a date for valid type', function () {
|
||||
const value = new Date().toUTCString();
|
||||
const value = new Date();
|
||||
expect(new RecordValue(RecordValueType.Date, 2, value).asDate())
|
||||
.to.deep.equal(new Date(value))
|
||||
.to.deep.equal(value)
|
||||
.and.to.be.a('date');
|
||||
});
|
||||
|
||||
@@ -136,23 +140,9 @@ describe('RecordValue', function () {
|
||||
|
||||
it('should return the value as an array of attachments for valid type', function () {
|
||||
const value = [
|
||||
{
|
||||
fileId: 1,
|
||||
fileName: 'test',
|
||||
notes: 'test',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
{
|
||||
fileId: 1,
|
||||
fileName: 'test',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
{
|
||||
fileId: 1,
|
||||
fileName: 'test',
|
||||
notes: null,
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
new Attachment(1, 'test', 'test', FileStorageSite.Internal),
|
||||
new Attachment(1, 'test', 'test', FileStorageSite.Internal),
|
||||
new Attachment(1, 'test', null, FileStorageSite.Internal),
|
||||
];
|
||||
|
||||
const attachmentArray = new RecordValue(
|
||||
@@ -172,25 +162,6 @@ describe('RecordValue', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error if attachment has incorrect storage location', function () {
|
||||
const value = [
|
||||
{
|
||||
fileId: 1,
|
||||
fileName: 'test',
|
||||
notes: 'test',
|
||||
storageLocation: 'Invalid',
|
||||
},
|
||||
];
|
||||
|
||||
expect(() =>
|
||||
new RecordValue(
|
||||
RecordValueType.AttachmentList,
|
||||
2,
|
||||
value
|
||||
).asAttachmentArray()
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if called on record value with incorrect type', function () {
|
||||
expect(() =>
|
||||
new RecordValue(RecordValueType.Integer, 2, []).asAttachmentArray()
|
||||
@@ -272,29 +243,31 @@ describe('RecordValue', function () {
|
||||
|
||||
it('should return the value as an array of delegates for valid type', function () {
|
||||
const value = [
|
||||
{
|
||||
delegateType: 'External',
|
||||
name: 'test',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationDateTime: '2019-01-01T00:00:00.000Z',
|
||||
delegationCompletedDateTime: '2019-01-01T00:00:00.000Z',
|
||||
},
|
||||
{
|
||||
delegateType: 'External',
|
||||
name: null,
|
||||
emailAddress: 'test@test.com',
|
||||
delegationDateTime: '2019-01-01T00:00:00.000Z',
|
||||
delegationCompletedDateTime: null,
|
||||
},
|
||||
{
|
||||
delegateType: 'External',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationDateTime: '2019-01-01T00:00:00.000Z',
|
||||
},
|
||||
new Delegate(
|
||||
DelegateType.External,
|
||||
'test',
|
||||
'test@test.com',
|
||||
new Date(),
|
||||
new Date()
|
||||
),
|
||||
new Delegate(
|
||||
DelegateType.External,
|
||||
null,
|
||||
'test@test.com',
|
||||
new Date(),
|
||||
null
|
||||
),
|
||||
new Delegate(
|
||||
DelegateType.External,
|
||||
'test',
|
||||
'test@test.com',
|
||||
new Date(),
|
||||
new Date()
|
||||
),
|
||||
];
|
||||
|
||||
const recordValue = new RecordValue(
|
||||
RecordValueType.ScoringGroupList,
|
||||
RecordValueType.DelegateList,
|
||||
2,
|
||||
value
|
||||
).asDelegateArray();
|
||||
@@ -315,26 +288,6 @@ describe('RecordValue', function () {
|
||||
new RecordValue(RecordValueType.Integer, 2, []).asDelegateArray()
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if delegate has incorrect delegate type', function () {
|
||||
const value = [
|
||||
{
|
||||
delegateType: 'Invalid',
|
||||
name: 'test',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationDateTime: '2019-01-01T00:00:00.000Z',
|
||||
delegationCompletedDateTime: '2019-01-01T00:00:00.000Z',
|
||||
},
|
||||
];
|
||||
|
||||
expect(() =>
|
||||
new RecordValue(
|
||||
RecordValueType.ScoringGroupList,
|
||||
2,
|
||||
value
|
||||
).asDelegateArray()
|
||||
).to.throw();
|
||||
});
|
||||
});
|
||||
|
||||
describe('asScoringGroupArray', function () {
|
||||
@@ -347,14 +300,7 @@ describe('RecordValue', function () {
|
||||
});
|
||||
|
||||
it('should return the value as an array of scoring groups for valid type', function () {
|
||||
const value = [
|
||||
{
|
||||
listValueId: 'test',
|
||||
name: 'test',
|
||||
score: 1,
|
||||
maximumScore: 1,
|
||||
},
|
||||
];
|
||||
const value = [new ScoringGroup('1', 'test', 1, 1)];
|
||||
|
||||
const recordValue = new RecordValue(
|
||||
RecordValueType.ScoringGroupList,
|
||||
@@ -391,24 +337,21 @@ describe('RecordValue', function () {
|
||||
|
||||
it('should return the value as a TimeSpanData for valid type', function () {
|
||||
const cases = [
|
||||
{
|
||||
quantity: 1,
|
||||
increment: 'Days',
|
||||
recurrence: 'None',
|
||||
endAfterOccurrences: 1,
|
||||
endByDate: '2019-01-01T00:00:00.000Z',
|
||||
},
|
||||
{
|
||||
quantity: 1,
|
||||
increment: 'Days',
|
||||
recurrence: null,
|
||||
endAfterOccurrences: null,
|
||||
endByDate: null,
|
||||
},
|
||||
{
|
||||
quantity: 1,
|
||||
increment: 'Days',
|
||||
},
|
||||
new TimeSpanData(
|
||||
1,
|
||||
TimeSpanIncrement.Days,
|
||||
TimeSpanRecurrenceType.None,
|
||||
1,
|
||||
new Date()
|
||||
),
|
||||
new TimeSpanData(1, TimeSpanIncrement.Days, null, null, null),
|
||||
new TimeSpanData(
|
||||
1,
|
||||
TimeSpanIncrement.Days,
|
||||
TimeSpanRecurrenceType.None,
|
||||
1,
|
||||
new Date()
|
||||
),
|
||||
];
|
||||
|
||||
cases.forEach((value) => {
|
||||
@@ -432,33 +375,5 @@ describe('RecordValue', function () {
|
||||
new RecordValue(RecordValueType.Integer, 2, []).asTimeSpanData()
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if timespan has incorrect increment', function () {
|
||||
const value = {
|
||||
quantity: 1,
|
||||
increment: 'Invalid',
|
||||
recurrence: 'None',
|
||||
endAfterOccurrences: 1,
|
||||
endByDate: '2019-01-01T00:00:00.000Z',
|
||||
};
|
||||
|
||||
expect(() =>
|
||||
new RecordValue(RecordValueType.TimeSpan, 2, value).asTimeSpanData()
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if timespan has incorrect recurrence', function () {
|
||||
const value = {
|
||||
quantity: 1,
|
||||
increment: 'Days',
|
||||
recurrence: 'Invalid',
|
||||
endAfterOccurrences: 1,
|
||||
endByDate: '2019-01-01T00:00:00.000Z',
|
||||
};
|
||||
|
||||
expect(() =>
|
||||
new RecordValue(RecordValueType.TimeSpan, 2, value).asTimeSpanData()
|
||||
).to.throw();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { ScoringGroupListRecordValue } from '../src/models/ScoringGroupListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('ScoringGroupListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(ScoringGroupListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(ScoringGroupListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(ScoringGroupListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const scoringGroupListRecordValue = new ScoringGroupListRecordValue(1, []);
|
||||
expect(scoringGroupListRecordValue).to.have.property('fieldId');
|
||||
expect(scoringGroupListRecordValue).to.have.property('value');
|
||||
expect(scoringGroupListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const scoringGroupListRecordValue = new ScoringGroupListRecordValue(1, []);
|
||||
expect(scoringGroupListRecordValue.fieldId).to.equal(1);
|
||||
expect(scoringGroupListRecordValue.value).to.deep.equal([]);
|
||||
expect(scoringGroupListRecordValue.type).to.equal('ScoringGroupList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { StringListRecordValue } from '../src/models/StringListRecordValue';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('StringListRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(StringListRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(StringListRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(StringListRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const stringListRecordValue = new StringListRecordValue(1, []);
|
||||
expect(stringListRecordValue).to.have.property('fieldId');
|
||||
expect(stringListRecordValue).to.have.property('value');
|
||||
expect(stringListRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const stringListRecordValue = new StringListRecordValue(1, []);
|
||||
expect(stringListRecordValue.fieldId).to.equal(1);
|
||||
expect(stringListRecordValue.value).to.deep.equal([]);
|
||||
expect(stringListRecordValue.type).to.equal('StringList');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import { TimeSpanRecordValue } from '../src/models/TimeSpanRecordValue';
|
||||
import { expect } from 'chai';
|
||||
import { TimeSpanData } from '../src/models/TimeSpanData';
|
||||
import { TimeSpanIncrement } from '../src/enums/TimeSpanIncrement';
|
||||
import { TimeSpanRecurrenceType } from '../src/enums/TimeSpanRecurrenceType';
|
||||
|
||||
describe('TimeSpanRecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(TimeSpanRecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(TimeSpanRecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should hav a constructor that takes a fieldId and value', function () {
|
||||
expect(TimeSpanRecordValue).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have fieldId, value, and type properties', function () {
|
||||
const timeSpanData = new TimeSpanData(
|
||||
1,
|
||||
TimeSpanIncrement.Days,
|
||||
TimeSpanRecurrenceType.None,
|
||||
null,
|
||||
null
|
||||
);
|
||||
const timeSpanRecordValue = new TimeSpanRecordValue(1, timeSpanData);
|
||||
expect(timeSpanRecordValue).to.have.property('fieldId');
|
||||
expect(timeSpanRecordValue).to.have.property('value');
|
||||
expect(timeSpanRecordValue).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const timeSpanData = new TimeSpanData(
|
||||
1,
|
||||
TimeSpanIncrement.Days,
|
||||
TimeSpanRecurrenceType.None,
|
||||
null,
|
||||
null
|
||||
);
|
||||
const timeSpanRecordValue = new TimeSpanRecordValue(1, timeSpanData);
|
||||
|
||||
expect(timeSpanRecordValue.fieldId).to.equal(1);
|
||||
expect(timeSpanRecordValue.value).to.deep.equal(timeSpanData);
|
||||
expect(timeSpanRecordValue.type).to.equal('TimeSpan');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
This file represents an exhaustive list of possible record value
|
||||
objects that can be returned from the API. It is used in the
|
||||
ApiResponse.spec.ts file to test the ApiResponse class when it returns
|
||||
types involving records.
|
||||
*/
|
||||
export const testFieldData: object[] = [
|
||||
{
|
||||
type: 'StringList',
|
||||
fieldId: 12891,
|
||||
value: ['list_value_1', 'list_value_2'],
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12144,
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12145,
|
||||
value: '2023-01-17T05:52:07.251Z',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12146,
|
||||
value: '2023-02-10T01:19:46.63Z',
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12152,
|
||||
value: 'stevan.freeborn@onspring.com',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12153,
|
||||
value: '2023-01-17T05:53:12.104Z',
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12160,
|
||||
value: 69,
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12165,
|
||||
value: 'stevan.freeborn+delegate@onspring.com',
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12166,
|
||||
value: 'stevan_delegate',
|
||||
},
|
||||
{
|
||||
type: 'ScoringGroupList',
|
||||
fieldId: 12167,
|
||||
value: [
|
||||
{
|
||||
delegateType: 'External',
|
||||
name: 'test_delegate',
|
||||
emailAddress: 'test@test.com',
|
||||
delegationType: 'AllPages',
|
||||
pageIds: [],
|
||||
answeredPageIds: [],
|
||||
canReadOtherPages: false,
|
||||
delegationDateTime: '2023-01-17T05:52:53.781Z',
|
||||
delegationCompletedDateTime: '2023-01-17T05:53:12.617Z',
|
||||
status: 'Pending',
|
||||
isDeleted: false,
|
||||
messagingDisplayText:
|
||||
'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM',
|
||||
guid: '00000000-0000-0000-0000-000000000000',
|
||||
},
|
||||
{
|
||||
delegateType: 'External',
|
||||
name: undefined,
|
||||
emailAddress: 'test@test.com',
|
||||
delegationType: 'AllPages',
|
||||
pageIds: [],
|
||||
answeredPageIds: [],
|
||||
canReadOtherPages: false,
|
||||
delegationDateTime: '2023-01-17T05:52:53.781Z',
|
||||
delegationCompletedDateTime: undefined,
|
||||
status: 'Pending',
|
||||
isDeleted: false,
|
||||
messagingDisplayText:
|
||||
'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM',
|
||||
guid: '00000000-0000-0000-0000-000000000000',
|
||||
},
|
||||
{
|
||||
delegateType: 'External',
|
||||
name: null,
|
||||
emailAddress: 'test@test.com',
|
||||
delegationType: 'AllPages',
|
||||
pageIds: [],
|
||||
answeredPageIds: [],
|
||||
canReadOtherPages: false,
|
||||
delegationDateTime: '2023-01-17T05:52:53.781Z',
|
||||
delegationCompletedDateTime: null,
|
||||
status: 'Pending',
|
||||
isDeleted: false,
|
||||
messagingDisplayText:
|
||||
'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM',
|
||||
guid: '00000000-0000-0000-0000-000000000000',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'IntegerList',
|
||||
fieldId: 12191,
|
||||
value: [1],
|
||||
},
|
||||
{
|
||||
type: 'IntegerList',
|
||||
fieldId: 12192,
|
||||
value: [925],
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12894,
|
||||
value: 'test',
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12895,
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
type: 'Guid',
|
||||
fieldId: 12896,
|
||||
value: '2b70ebb9-af45-4165-9a23-da44acce7bf7',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12897,
|
||||
value: '2023-02-10T07:19:46.629Z',
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12144,
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12145,
|
||||
value: '2023-01-24T04:03:06.13Z',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12146,
|
||||
value: '2023-02-10T04:06:29.985Z',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12147,
|
||||
value: '2023-02-10T04:06:29.985Z',
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12148,
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12149,
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12150,
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12151,
|
||||
value: 'Stevan Freeborn',
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12152,
|
||||
value: 'stevan.freeborn@onspring.com',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12153,
|
||||
value: '2023-01-24T04:03:06.128Z',
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12155,
|
||||
value: 6,
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12156,
|
||||
value: 9,
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12157,
|
||||
value: 66.66666666666667,
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12160,
|
||||
value: 73,
|
||||
},
|
||||
{
|
||||
type: 'ScoringGroupList',
|
||||
fieldId: 12161,
|
||||
value: [
|
||||
{
|
||||
listValueId: '0eac7224-f4bc-4121-8ca5-1fe75f5cd576',
|
||||
name: 'group_one',
|
||||
score: 2,
|
||||
maximumScore: 3,
|
||||
},
|
||||
{
|
||||
listValueId: '743ddd0d-702d-414d-87d4-0aa4fe0c265e',
|
||||
name: 'group_two',
|
||||
score: 2,
|
||||
maximumScore: 4,
|
||||
},
|
||||
{
|
||||
listValueId: '4ff35205-bfe8-4639-8574-d0458fa7f85e',
|
||||
name: 'group_three',
|
||||
score: 2,
|
||||
maximumScore: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12162,
|
||||
value: 9,
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12163,
|
||||
value: 66.66666666666667,
|
||||
},
|
||||
{
|
||||
type: 'ScoringGroupList',
|
||||
fieldId: 12164,
|
||||
value: [
|
||||
{
|
||||
listValueId: '0eac7224-f4bc-4121-8ca5-1fe75f5cd576',
|
||||
name: 'group_one',
|
||||
score: 2,
|
||||
maximumScore: 3,
|
||||
},
|
||||
{
|
||||
listValueId: '743ddd0d-702d-414d-87d4-0aa4fe0c265e',
|
||||
name: 'group_two',
|
||||
score: 2,
|
||||
maximumScore: 4,
|
||||
},
|
||||
{
|
||||
listValueId: '4ff35205-bfe8-4639-8574-d0458fa7f85e',
|
||||
name: 'group_three',
|
||||
score: 2,
|
||||
maximumScore: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12165,
|
||||
value: 'stevan.freeborn@onspring.com',
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12166,
|
||||
value: 'Stevan Freeborn',
|
||||
},
|
||||
{
|
||||
type: 'IntegerList',
|
||||
fieldId: 12191,
|
||||
value: [2, 3, 4, 5, 6, 7],
|
||||
},
|
||||
{
|
||||
type: 'IntegerList',
|
||||
fieldId: 12192,
|
||||
value: [925],
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12263,
|
||||
value: '2',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12884,
|
||||
value: '2023-02-09T06:00:00Z',
|
||||
},
|
||||
{
|
||||
type: 'Guid',
|
||||
fieldId: 12885,
|
||||
value: 'e75b49cf-adb7-4b8e-a7e5-93ebf1948dba',
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12886,
|
||||
value: 100,
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12887,
|
||||
value: 'this is a test',
|
||||
},
|
||||
{
|
||||
type: 'AttachmentList',
|
||||
fieldId: 12888,
|
||||
value: [
|
||||
{
|
||||
fileId: 1348,
|
||||
fileName: 'onspring-api-playground.py',
|
||||
notes: '',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
{
|
||||
fileId: 1349,
|
||||
fileName: 'core_isolation_warning.png',
|
||||
notes: '',
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
{
|
||||
fileId: 1349,
|
||||
fileName: 'core_isolation_warning.png',
|
||||
notes: null,
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
{
|
||||
fileId: 1349,
|
||||
fileName: 'core_isolation_warning.png',
|
||||
notes: undefined,
|
||||
storageLocation: 'Internal',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'FileList',
|
||||
fieldId: 12889,
|
||||
value: [1350, 1351],
|
||||
},
|
||||
{
|
||||
type: 'Integer',
|
||||
fieldId: 12890,
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
type: 'GuidList',
|
||||
fieldId: 12891,
|
||||
value: [
|
||||
'd7471a5f-6718-4368-8734-3e3e712bacd9',
|
||||
'3b3de61f-fa44-4e51-b70d-35992c2a1a6e',
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'IntegerList',
|
||||
fieldId: 12892,
|
||||
value: [4, 5],
|
||||
},
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Days',
|
||||
recurrence: 'EndByDate',
|
||||
endAfterOccurrences: 10,
|
||||
endByDate: '2023-02-16T06:00:00Z',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Days',
|
||||
recurrence: null,
|
||||
endAfterOccurrences: null,
|
||||
endByDate: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'TimeSpan',
|
||||
fieldId: 12893,
|
||||
value: {
|
||||
quantity: 10,
|
||||
increment: 'Days',
|
||||
recurrence: undefined,
|
||||
endAfterOccurrences: undefined,
|
||||
endByDate: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'String',
|
||||
fieldId: 12894,
|
||||
value: 'test',
|
||||
},
|
||||
{
|
||||
type: 'Decimal',
|
||||
fieldId: 12895,
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
type: 'Guid',
|
||||
fieldId: 12896,
|
||||
value: '2b70ebb9-af45-4165-9a23-da44acce7bf7',
|
||||
},
|
||||
{
|
||||
type: 'Date',
|
||||
fieldId: 12897,
|
||||
value: '2023-02-10T07:19:47.002Z',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user