Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Fix date range to reset calculatorIds #43

Merged
merged 1 commit into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {},
"devDependencies": {
"@blackbaud/skyux": "2.48.3",
"@blackbaud/skyux-builder": "1.34.0",
"@blackbaud/skyux-builder": "1.34.1",
"@skyux-sdk/builder-plugin-skyux": "1.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ import {
SkyDateRangeCalculatorType
} from './types/date-range-calculator-type';

const defaultCalculatorIds = [
SkyDateRangeCalculatorId.AnyTime,
SkyDateRangeCalculatorId.Before,
SkyDateRangeCalculatorId.After,
SkyDateRangeCalculatorId.SpecificRange,
SkyDateRangeCalculatorId.Yesterday,
SkyDateRangeCalculatorId.Today,
SkyDateRangeCalculatorId.Tomorrow,
SkyDateRangeCalculatorId.LastWeek,
SkyDateRangeCalculatorId.ThisWeek,
SkyDateRangeCalculatorId.NextWeek,
SkyDateRangeCalculatorId.LastMonth,
SkyDateRangeCalculatorId.ThisMonth,
SkyDateRangeCalculatorId.NextMonth,
SkyDateRangeCalculatorId.LastQuarter,
SkyDateRangeCalculatorId.ThisQuarter,
SkyDateRangeCalculatorId.NextQuarter,
SkyDateRangeCalculatorId.LastCalendarYear,
SkyDateRangeCalculatorId.ThisCalendarYear,
SkyDateRangeCalculatorId.NextCalendarYear,
SkyDateRangeCalculatorId.LastFiscalYear,
SkyDateRangeCalculatorId.ThisFiscalYear,
SkyDateRangeCalculatorId.NextFiscalYear
];

describe('Date range picker', function () {
let fixture: ComponentFixture<DateRangePickerTestComponent>;
let component: DateRangePickerTestComponent;
Expand Down Expand Up @@ -134,30 +159,7 @@ describe('Date range picker', function () {
const picker = component.dateRangePicker;
expect(picker.dateFormat).toEqual('MM/DD/YYYY');
expect(picker.label).toEqual(undefined);
expect(picker.calculatorIds).toEqual([
SkyDateRangeCalculatorId.AnyTime,
SkyDateRangeCalculatorId.Before,
SkyDateRangeCalculatorId.After,
SkyDateRangeCalculatorId.SpecificRange,
SkyDateRangeCalculatorId.Yesterday,
SkyDateRangeCalculatorId.Today,
SkyDateRangeCalculatorId.Tomorrow,
SkyDateRangeCalculatorId.LastWeek,
SkyDateRangeCalculatorId.ThisWeek,
SkyDateRangeCalculatorId.NextWeek,
SkyDateRangeCalculatorId.LastMonth,
SkyDateRangeCalculatorId.ThisMonth,
SkyDateRangeCalculatorId.NextMonth,
SkyDateRangeCalculatorId.LastQuarter,
SkyDateRangeCalculatorId.ThisQuarter,
SkyDateRangeCalculatorId.NextQuarter,
SkyDateRangeCalculatorId.LastCalendarYear,
SkyDateRangeCalculatorId.ThisCalendarYear,
SkyDateRangeCalculatorId.NextCalendarYear,
SkyDateRangeCalculatorId.LastFiscalYear,
SkyDateRangeCalculatorId.ThisFiscalYear,
SkyDateRangeCalculatorId.NextFiscalYear
]);
expect(picker.calculatorIds).toEqual(defaultCalculatorIds);
}));

it('should allow setting specific calculators', fakeAsync(function () {
Expand All @@ -174,6 +176,13 @@ describe('Date range picker', function () {
SkyDateRangeCalculatorId.After,
SkyDateRangeCalculatorId.SpecificRange
]);

// Reset the calculators to verify defaults are set.
component.calculatorIds = undefined;

detectChanges();

expect(component.dateRangePicker.calculatorIds).toEqual(defaultCalculatorIds);
}));

it('should allow setting calculators asynchronously', fakeAsync(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ export class SkyDateRangePickerComponent

@Input()
public set calculatorIds(value: SkyDateRangeCalculatorId[]) {
if (value) {
this._calculatorIds = value;
}
this._calculatorIds = value;
}

public get calculatorIds(): SkyDateRangeCalculatorId[] {
Expand Down