2023-02-09 22:21:20 -06:00
|
|
|
import { TimeSpanData } from '../src/models/TimeSpanData';
|
|
|
|
|
import { expect } from 'chai';
|
2023-02-10 23:22:41 -06:00
|
|
|
import { TimeSpanIncrement } from '../src/enums/TimeSpanIncrement';
|
|
|
|
|
import { TimeSpanRecurrenceType } from '../src/enums/TimeSpanRecurrenceType';
|
2023-02-09 22:21:20 -06:00
|
|
|
|
|
|
|
|
describe('TimeSpanData', function () {
|
2023-02-10 23:22:41 -06:00
|
|
|
it('should be defined', function () {
|
|
|
|
|
expect(TimeSpanData).to.not.be.undefined;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have a constructor', function () {
|
|
|
|
|
expect(TimeSpanData).to.have.property('constructor');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have a constructor that takes 5 parameters', function () {
|
|
|
|
|
expect(TimeSpanData).to.have.lengthOf(5);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have a quantity property', function () {
|
|
|
|
|
expect(
|
|
|
|
|
new TimeSpanData(
|
|
|
|
|
1,
|
|
|
|
|
TimeSpanIncrement.Days,
|
|
|
|
|
TimeSpanRecurrenceType.None,
|
|
|
|
|
1,
|
|
|
|
|
new Date()
|
|
|
|
|
)
|
|
|
|
|
).to.have.property('quantity');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have an increment property', function () {
|
|
|
|
|
expect(
|
|
|
|
|
new TimeSpanData(
|
|
|
|
|
1,
|
|
|
|
|
TimeSpanIncrement.Days,
|
|
|
|
|
TimeSpanRecurrenceType.None,
|
|
|
|
|
1,
|
|
|
|
|
new Date()
|
|
|
|
|
)
|
|
|
|
|
).to.have.property('increment');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have a recurrence property', function () {
|
|
|
|
|
expect(
|
|
|
|
|
new TimeSpanData(
|
|
|
|
|
1,
|
|
|
|
|
TimeSpanIncrement.Days,
|
|
|
|
|
TimeSpanRecurrenceType.None,
|
|
|
|
|
1,
|
|
|
|
|
new Date()
|
|
|
|
|
)
|
|
|
|
|
).to.have.property('recurrence');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have an endAfterOccurrences property', function () {
|
|
|
|
|
expect(
|
|
|
|
|
new TimeSpanData(
|
|
|
|
|
1,
|
|
|
|
|
TimeSpanIncrement.Days,
|
|
|
|
|
TimeSpanRecurrenceType.None,
|
|
|
|
|
1,
|
|
|
|
|
new Date()
|
|
|
|
|
)
|
|
|
|
|
).to.have.property('endAfterOccurrences');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have an endByDate property', function () {
|
|
|
|
|
expect(
|
|
|
|
|
new TimeSpanData(
|
|
|
|
|
1,
|
|
|
|
|
TimeSpanIncrement.Days,
|
|
|
|
|
TimeSpanRecurrenceType.None,
|
|
|
|
|
1,
|
|
|
|
|
new Date()
|
|
|
|
|
)
|
|
|
|
|
).to.have.property('endByDate');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should have a constructor that sets its properties correctly', function () {
|
|
|
|
|
const quantity = 1;
|
|
|
|
|
const increment = TimeSpanIncrement.Days;
|
|
|
|
|
const recurrence = TimeSpanRecurrenceType.None;
|
|
|
|
|
const endAfterOccurrences = 1;
|
|
|
|
|
const endByDate = new Date();
|
|
|
|
|
|
|
|
|
|
const timeSpanData = new TimeSpanData(
|
|
|
|
|
quantity,
|
|
|
|
|
increment,
|
|
|
|
|
recurrence,
|
|
|
|
|
endAfterOccurrences,
|
|
|
|
|
endByDate
|
|
|
|
|
);
|
|
|
|
|
expect(timeSpanData).to.have.property('quantity', quantity);
|
|
|
|
|
expect(timeSpanData).to.have.property('increment', increment);
|
|
|
|
|
expect(timeSpanData).to.have.property('recurrence', recurrence);
|
|
|
|
|
expect(timeSpanData).to.have.property(
|
|
|
|
|
'endAfterOccurrences',
|
|
|
|
|
endAfterOccurrences
|
|
|
|
|
);
|
|
|
|
|
expect(timeSpanData).to.have.property('endByDate', endByDate);
|
|
|
|
|
});
|
2023-02-09 22:21:20 -06:00
|
|
|
});
|