fix(schedule): don’t massage null value

This commit is contained in:
Rhys Arkins 2018-10-05 09:59:32 +02:00
parent 3b387e92db
commit 77997770f1
4 changed files with 8 additions and 5 deletions

View file

@ -214,10 +214,7 @@ function migrateConfig(config) {
isMigrated = true;
migratedConfig.baseBranches = is.array(val) ? val : [val];
delete migratedConfig.baseBranch;
} else if (key === 'schedule' && !val) {
isMigrated = true;
migratedConfig.schedule = [];
} else if (key === 'schedule') {
} else if (key === 'schedule' && val) {
// massage to array first
const schedules = is.string(val) ? [val] : val;
// split 'and'

View file

@ -21,6 +21,9 @@ function hasValidTimezone(timezone) {
function hasValidSchedule(schedule) {
let message;
if (!schedule) {
return [true];
}
// check if any of the schedules fail to parse
const hasFailedSchedules = schedule.some(scheduleText => {
const massagedText = fixShortHours(scheduleText);

View file

@ -98,7 +98,7 @@ Object {
"minor": Object {
"automerge": true,
},
"schedule": Array [],
"schedule": null,
},
Object {
"depTypeList": Array [

View file

@ -14,6 +14,9 @@ describe('workers/branch/schedule', () => {
beforeEach(() => {
jest.resetAllMocks();
});
it('returns true for null', () => {
expect(schedule.hasValidSchedule(null)[0]).toBe(true);
});
it('returns false for invalid schedule', () => {
expect(schedule.hasValidSchedule(['foo'])[0]).toBe(false);
});