feat: begin working on implementing record methods
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import { Attachment } from '../src/models/Attachment';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('Attachment', function () {
|
||||
throw new Error('Not implemented');
|
||||
});
|
||||
+28
-28
@@ -1,4 +1,6 @@
|
||||
import { expect } from 'chai';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { Field } from '../src/models/Field';
|
||||
|
||||
describe('Field', function () {
|
||||
@@ -16,38 +18,36 @@ describe('Field', function () {
|
||||
|
||||
it('should create a new instance of the Field class', function () {
|
||||
expect(
|
||||
() => new Field(1, 1, 'Text Field', 'Text', 'Enabled', true, false)
|
||||
() =>
|
||||
new Field(
|
||||
1,
|
||||
1,
|
||||
'Text Field',
|
||||
FieldType.Text,
|
||||
FieldStatus.Enabled,
|
||||
true,
|
||||
false
|
||||
)
|
||||
).to.not.throw();
|
||||
});
|
||||
|
||||
it('should throw an error when the type parameter is not a valid value', function () {
|
||||
expect(
|
||||
() => new Field(1, 1, 'Text Field', 'Invalid', 'Enabled', true, false)
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error when the status parameter is not a valid value', function () {
|
||||
expect(
|
||||
() => new Field(1, 1, 'Text Field', 'Text', 'Unabled', true, false)
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should create a new instance of the Field class with the correct properties and values', function () {
|
||||
const field = new Field(1, 1, 'Text Field', 'Text', 'Enabled', true, false);
|
||||
const field = new Field(
|
||||
1,
|
||||
1,
|
||||
'Text Field',
|
||||
FieldType.Text,
|
||||
FieldStatus.Enabled,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
expect(field).to.have.property('id');
|
||||
expect(field).to.have.property('appId');
|
||||
expect(field).to.have.property('name');
|
||||
expect(field).to.have.property('type');
|
||||
expect(field).to.have.property('status');
|
||||
expect(field).to.have.property('isRequired');
|
||||
expect(field).to.have.property('isUnique');
|
||||
expect(field.id).to.equal(1);
|
||||
expect(field.appId).to.equal(1);
|
||||
expect(field.name).to.equal('Text Field');
|
||||
expect(field.type).to.equal('Text');
|
||||
expect(field.status).to.equal('Enabled');
|
||||
expect(field.isRequired).to.equal(true);
|
||||
expect(field.isUnique).to.equal(false);
|
||||
expect(field).to.have.property('id', 1);
|
||||
expect(field).to.have.property('appId', 1);
|
||||
expect(field).to.have.property('name', 'Text Field');
|
||||
expect(field).to.have.property('type', FieldType.Text);
|
||||
expect(field).to.have.property('status', FieldStatus.Enabled);
|
||||
expect(field).to.have.property('isRequired', true);
|
||||
expect(field).to.have.property('isUnique', false);
|
||||
});
|
||||
});
|
||||
|
||||
+12
-26
@@ -1,5 +1,8 @@
|
||||
import { FormulaField } from '../src/models/FormulaField';
|
||||
import { expect } from 'chai';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { FormulaOutputType } from '../src/enums/FormulaOutputType';
|
||||
|
||||
describe('FormulaField', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -14,33 +17,16 @@ describe('FormulaField', function () {
|
||||
expect(FormulaField).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should throw an error if the outputType is not a valid FormulaOutputType', function () {
|
||||
expect(
|
||||
() =>
|
||||
new FormulaField(
|
||||
1,
|
||||
1,
|
||||
'Formula Field',
|
||||
'Formula',
|
||||
'Enabled',
|
||||
false,
|
||||
false,
|
||||
'NotAType',
|
||||
[]
|
||||
)
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should create a new FormulaField', function () {
|
||||
const formulaField = new FormulaField(
|
||||
1,
|
||||
1,
|
||||
'Formula Field',
|
||||
'Formula',
|
||||
'Enabled',
|
||||
FieldType.Formula,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'Text',
|
||||
FormulaOutputType.Text,
|
||||
[]
|
||||
);
|
||||
expect(formulaField).to.be.an.instanceOf(FormulaField);
|
||||
@@ -51,11 +37,11 @@ describe('FormulaField', function () {
|
||||
1,
|
||||
1,
|
||||
'Formula Field',
|
||||
'Formula',
|
||||
'Enabled',
|
||||
FieldType.Formula,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'Text',
|
||||
FormulaOutputType.Text,
|
||||
[]
|
||||
);
|
||||
expect(formulaField).to.have.property('outputType');
|
||||
@@ -66,11 +52,11 @@ describe('FormulaField', function () {
|
||||
1,
|
||||
1,
|
||||
'Formula Field',
|
||||
'Formula',
|
||||
'Enabled',
|
||||
FieldType.Formula,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'Text',
|
||||
FormulaOutputType.Text,
|
||||
[]
|
||||
);
|
||||
expect(formulaField).to.have.property('values');
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { GetPagedFieldsResponse } from '../src/models/GetPagedFieldsResponse';
|
||||
import { Field } from '../src/models/Field';
|
||||
import { expect } from 'chai';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
|
||||
describe('GetPagedFieldsResponse', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -17,7 +19,17 @@ describe('GetPagedFieldsResponse', function () {
|
||||
|
||||
it('should construct a new instance of GetPagedFieldsResponse', function () {
|
||||
const getPagedFieldsResponse = new GetPagedFieldsResponse(
|
||||
[new Field(1, 1, 'Text Field 1', 'Text', 'Enabled', false, false)],
|
||||
[
|
||||
new Field(
|
||||
1,
|
||||
1,
|
||||
'Text Field 1',
|
||||
FieldType.Text,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false
|
||||
),
|
||||
],
|
||||
1,
|
||||
10,
|
||||
100,
|
||||
|
||||
+15
-30
@@ -1,5 +1,8 @@
|
||||
import { ListField } from '../src/models/ListField';
|
||||
import { expect } from 'chai';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { Multiplicity } from '../src/enums/Multiplicity';
|
||||
|
||||
describe('ListField', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -14,34 +17,16 @@ describe('ListField', function () {
|
||||
expect(ListField).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should throw an error if the multiplicity is not valid', function () {
|
||||
expect(
|
||||
() =>
|
||||
new ListField(
|
||||
1,
|
||||
1,
|
||||
'List Field',
|
||||
'List',
|
||||
'Enabled',
|
||||
false,
|
||||
false,
|
||||
'Alone',
|
||||
1,
|
||||
[]
|
||||
)
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should create a new ListField', function () {
|
||||
const listField = new ListField(
|
||||
1,
|
||||
1,
|
||||
'List Field',
|
||||
'List',
|
||||
'Enabled',
|
||||
FieldType.List,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1,
|
||||
[]
|
||||
);
|
||||
@@ -53,11 +38,11 @@ describe('ListField', function () {
|
||||
1,
|
||||
1,
|
||||
'List Field',
|
||||
'List',
|
||||
'Enabled',
|
||||
FieldType.List,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1,
|
||||
[]
|
||||
);
|
||||
@@ -69,11 +54,11 @@ describe('ListField', function () {
|
||||
1,
|
||||
1,
|
||||
'List Field',
|
||||
'List',
|
||||
'Enabled',
|
||||
FieldType.List,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1,
|
||||
[]
|
||||
);
|
||||
@@ -85,11 +70,11 @@ describe('ListField', function () {
|
||||
1,
|
||||
1,
|
||||
'List Field',
|
||||
'List',
|
||||
'Enabled',
|
||||
FieldType.List,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1,
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { Record } from '../src/models/Record';
|
||||
import { expect } from 'chai';
|
||||
import { RecordValueType } from '../src/enums/RecordValueType';
|
||||
|
||||
describe('Record', function () {
|
||||
it('should be defined', function () {
|
||||
expect(Record).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(Record).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should have a constructor that has 3 parameters', function () {
|
||||
expect(Record).to.have.lengthOf(3);
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const record = new Record(1, 2, [
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 1,
|
||||
value: 'test',
|
||||
},
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 2,
|
||||
value: 'test',
|
||||
},
|
||||
]);
|
||||
expect(record).to.have.property('appId', 1);
|
||||
expect(record).to.have.property('recordId', 2);
|
||||
expect(record)
|
||||
.to.have.property('fieldData')
|
||||
.that.is.an('array')
|
||||
.with.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have an appId property', function () {
|
||||
expect(
|
||||
new Record(1, 2, [
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 1,
|
||||
value: 'test',
|
||||
},
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 2,
|
||||
value: 'test',
|
||||
},
|
||||
])
|
||||
).to.have.property('appId');
|
||||
});
|
||||
|
||||
it('should have a recordId property', function () {
|
||||
expect(
|
||||
new Record(1, 2, [
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 1,
|
||||
value: 'test',
|
||||
},
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 2,
|
||||
value: 'test',
|
||||
},
|
||||
])
|
||||
).to.have.property('recordId');
|
||||
});
|
||||
|
||||
it('should have a fieldData property', function () {
|
||||
expect(
|
||||
new Record(1, 2, [
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 1,
|
||||
value: 'test',
|
||||
},
|
||||
{
|
||||
type: RecordValueType.String,
|
||||
fieldId: 2,
|
||||
value: 'test',
|
||||
},
|
||||
])
|
||||
).to.have.property('fieldData');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
import { RecordValue } from '../src/models/RecordValue';
|
||||
import { expect } from 'chai';
|
||||
import { RecordValueType } from '../src/enums/RecordValueType';
|
||||
|
||||
describe('RecordValue', function () {
|
||||
it('should be defined', function () {
|
||||
expect(RecordValue).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(RecordValue).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should have a constructor that has 3 parameters', function () {
|
||||
expect(RecordValue).to.have.lengthOf(3);
|
||||
});
|
||||
|
||||
it('should have a constructor that sets its properties correctly', function () {
|
||||
const recordValue = new RecordValue(
|
||||
RecordValueType.Date,
|
||||
2,
|
||||
new Date().toUTCString()
|
||||
);
|
||||
expect(recordValue).to.have.property('type', RecordValueType.Date);
|
||||
expect(recordValue).to.have.property('fieldId', 2);
|
||||
expect(recordValue).to.have.property('value', new Date().toUTCString());
|
||||
});
|
||||
|
||||
it('should have a type property', function () {
|
||||
expect(
|
||||
new RecordValue(RecordValueType.Date, 2, new Date().toUTCString())
|
||||
).to.have.property('type');
|
||||
});
|
||||
|
||||
it('should have a fieldId property', function () {
|
||||
expect(
|
||||
new RecordValue(RecordValueType.Date, 2, new Date().toUTCString())
|
||||
).to.have.property('fieldId');
|
||||
});
|
||||
|
||||
it('should have a value property', function () {
|
||||
expect(
|
||||
new RecordValue(RecordValueType.Date, 2, new Date().toUTCString())
|
||||
).to.have.property('value');
|
||||
});
|
||||
});
|
||||
@@ -1,87 +1,87 @@
|
||||
import { ResultValueType } from '../src/enums/ResultValueType';
|
||||
import { RecordValueType } from '../src/enums/RecordValueType';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('ResultValueType', function () {
|
||||
describe('RecordValueType', function () {
|
||||
describe('String', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.String;
|
||||
const result = RecordValueType.String;
|
||||
expect(result).to.equal('String');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Integer', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.Integer;
|
||||
const result = RecordValueType.Integer;
|
||||
expect(result).to.equal('Integer');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Decimal', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.Decimal;
|
||||
const result = RecordValueType.Decimal;
|
||||
expect(result).to.equal('Decimal');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Date', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.Date;
|
||||
const result = RecordValueType.Date;
|
||||
expect(result).to.equal('Date');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TimeSpan', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.TimeSpan;
|
||||
const result = RecordValueType.TimeSpan;
|
||||
expect(result).to.equal('TimeSpan');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Guid', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.Guid;
|
||||
const result = RecordValueType.Guid;
|
||||
expect(result).to.equal('Guid');
|
||||
});
|
||||
});
|
||||
|
||||
describe('StringList', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.StringList;
|
||||
const result = RecordValueType.StringList;
|
||||
expect(result).to.equal('StringList');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IntegerList', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.IntegerList;
|
||||
const result = RecordValueType.IntegerList;
|
||||
expect(result).to.equal('IntegerList');
|
||||
});
|
||||
});
|
||||
|
||||
describe('GuidList', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.GuidList;
|
||||
const result = RecordValueType.GuidList;
|
||||
expect(result).to.equal('GuidList');
|
||||
});
|
||||
});
|
||||
|
||||
describe('AttachmentList', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.AttachmentList;
|
||||
const result = RecordValueType.AttachmentList;
|
||||
expect(result).to.equal('AttachmentList');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ScoringGroupList', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.ScoringGroupList;
|
||||
const result = RecordValueType.ScoringGroupList;
|
||||
expect(result).to.equal('ScoringGroupList');
|
||||
});
|
||||
});
|
||||
|
||||
describe('FileList', function () {
|
||||
it('should return the correct value', function () {
|
||||
const result = ResultValueType.FileList;
|
||||
const result = RecordValueType.FileList;
|
||||
expect(result).to.equal('FileList');
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,8 @@
|
||||
import { ReferenceField } from '../src/models/ReferenceField';
|
||||
import { expect } from 'chai';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { Multiplicity } from '../src/enums/Multiplicity';
|
||||
|
||||
describe('ReferenceField', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -14,33 +17,16 @@ describe('ReferenceField', function () {
|
||||
expect(ReferenceField).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should throw an error if the multiplicity is not valid', function () {
|
||||
expect(
|
||||
() =>
|
||||
new ReferenceField(
|
||||
1,
|
||||
1,
|
||||
'Reference Field',
|
||||
'Reference',
|
||||
'Enabled',
|
||||
false,
|
||||
false,
|
||||
'Alone',
|
||||
1
|
||||
)
|
||||
).to.throw();
|
||||
});
|
||||
|
||||
it('should create a new ReferenceField', function () {
|
||||
const referenceField = new ReferenceField(
|
||||
1,
|
||||
1,
|
||||
'Reference Field',
|
||||
'Reference',
|
||||
'Enabled',
|
||||
FieldType.Reference,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1
|
||||
);
|
||||
expect(referenceField).to.be.an.instanceOf(ReferenceField);
|
||||
@@ -51,11 +37,11 @@ describe('ReferenceField', function () {
|
||||
1,
|
||||
1,
|
||||
'Reference Field',
|
||||
'Reference',
|
||||
'Enabled',
|
||||
FieldType.Reference,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1
|
||||
);
|
||||
expect(referenceField).to.have.property('multiplicity');
|
||||
@@ -66,11 +52,11 @@ describe('ReferenceField', function () {
|
||||
1,
|
||||
1,
|
||||
'Reference Field',
|
||||
'Reference',
|
||||
'Enabled',
|
||||
FieldType.Reference,
|
||||
FieldStatus.Enabled,
|
||||
false,
|
||||
false,
|
||||
'SingleSelect',
|
||||
Multiplicity.SingleSelect,
|
||||
1
|
||||
);
|
||||
expect(referenceField).to.have.property('referencedAppId');
|
||||
|
||||
@@ -27,4 +27,28 @@ describe('Report', function () {
|
||||
expect(report.name).to.be.equal('report');
|
||||
expect(report.description).to.be.equal('report description');
|
||||
});
|
||||
|
||||
it('should have an id property', function () {
|
||||
expect(new Report(1, 1, 'report', 'report description')).to.have.property(
|
||||
'id'
|
||||
);
|
||||
});
|
||||
|
||||
it('should have an appId property', function () {
|
||||
expect(new Report(1, 1, 'report', 'report description')).to.have.property(
|
||||
'appId'
|
||||
);
|
||||
});
|
||||
|
||||
it('should have a name property', function () {
|
||||
expect(new Report(1, 1, 'report', 'report description')).to.have.property(
|
||||
'name'
|
||||
);
|
||||
});
|
||||
|
||||
it('should have a description property', function () {
|
||||
expect(new Report(1, 1, 'report', 'report description')).to.have.property(
|
||||
'description'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,4 +47,12 @@ describe('ReportData', function () {
|
||||
.with.lengthOf(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have a columns property', function () {
|
||||
expect(new ReportData(['a', 'b'], [])).to.have.property('columns');
|
||||
});
|
||||
|
||||
it('should have a rows property', function () {
|
||||
expect(new ReportData(['a', 'b'], [])).to.have.property('rows');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,4 +16,12 @@ describe('Row', function () {
|
||||
expect(row).to.have.property('recordId', 1);
|
||||
expect(row).to.have.property('cells').that.is.an('array').with.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should have a recordId property', function () {
|
||||
expect(new Row(1, [{}, {}])).to.have.property('recordId');
|
||||
});
|
||||
|
||||
it('should have a cells property', function () {
|
||||
expect(new Row(1, [{}, {}])).to.have.property('cells');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ScoringGroup } from '../src/models/ScoringGroup';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('ScoringGroup', function () {
|
||||
throw new Error('Not implemented');
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { TimeSpanData } from '../src/models/TimeSpanData';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('TimeSpanData', function () {
|
||||
throw new Error('Not implemented');
|
||||
});
|
||||
Reference in New Issue
Block a user