it("should correctly dispatch errorRanges", function() { let error: Error = new Error("An error occurred"); state = reducer(state, raft.errorRanges(error)); assert.isNotTrue(state.inFlight); assert.isNotTrue(state.isValid); assert.deepEqual(state.lastError, error); });
it('should allow excluding time', function () { const schedule = new Schedule(); assert.isNotTrue(schedule.isWithinTimeslot(new Date()), 'Default to have no timeslot selected'); schedule.includeHour(0); assert.isTrue(schedule.isWithinTimeslot(new Date(2016, 8, 11, 0, 0, 0)), 'should within timeslot'); schedule.excludeHour(0); assert.isNotTrue(schedule.isWithinTimeslot(new Date(2016, 8, 11, 0, 0, 0)), 'timeslot just excluded'); assert.throw(() => { schedule.excludeHour(24); }, 'value should between 0-23'); assert.throw(() => { schedule.excludeHour(-1); }, 'value should between 0-23'); });
it("should correctly dispatch receiveRanges", function() { let response = new protos.cockroach.server.serverpb.RaftDebugResponse({}); state = reducer(state, raft.receiveRanges(response)); assert.isNotTrue(state.inFlight); assert.isTrue(state.isValid); assert.deepEqual(state.statuses, response); assert.isNull(state.lastError); });
return p.then((): Promise<void> => { assert.isNull(mockDebugState.lastError); assert.isTrue(mockDebugState.isValid); assert.isNotTrue(mockDebugState.inFlight); mockDebugState.isValid = false; // second request should throw an error let p2 = refreshRaft(); assert.isTrue(mockDebugState.inFlight); return p2; }).then(() => {
}).then(() => { // Assert that the server got the correct number of requests (2). assert.lengthOf(fetchMock.calls("/_status/raft"), 2); assert.isNotNull(mockDebugState.lastError); assert.isNotTrue(mockDebugState.inFlight); });