<commit_before>import task from "../../app/reducers/task";
import {
  addTask,
  removeTask,
  completeTask,
  activateTask,
  deactivateTask
} from "../../app/actions/task";

describe("task", () => {
  const mockState = [
    {
      name: "<NAME>",
      currentProgress: 0,
      totalPomodoros: 1,
      stopped: 0,
      active: false
    }
  ];

  it("should be defined", () => {
    expect(task).toBeDefined();
  });

  it("should handle initial state", () => {
    expect(task(undefined, [])).toMatchSnapshot();
  });

  describe("add task", () => {
    it("should add tasks", () => {
      expect(task([], addTask("Save the world", 1))).toEqual(mockState);
    });

    it("shouldn't add tasks that are already added", () => {
      //
      expect(task(mockState, addTask("Save the world", 100)).length).toEqual(1);
    });

    it("shouldn't override tasks that are already added", () => {
      //
      expect(task(mockState, addTask("Save the world", 100))).toEqual(
        mockState
      );
    });
  });

  describe("remove task", () => {
    it("should remove tasks", () => {
      expect(task(mockState, removeTask("Save the world")).length).toBe(0);
    });
  });

  describe("complete task", () => {
    it("should temporarily remove tasks", () => {
      expect(task(mockState, completeTask("Save the world")).length).toBe(0);
    });
  });

  describe("activate task", () => {
    it("should change a task state to active", () => {
      expect(task(mockState, activateTask("Save the world"))[0].active).toBe(
        true
      );
    });

    it("should do nothing to an active task", () => {
      const activeMockState = task(mockState, activateTask("Save the world"));

      expect(task(activeMockState, activateTask("Save the world"))).toEqual(
        activeMockState
      );
    });

    it("should not change anything about non-related tasks", () => {
      const state = task(mockState, addTask("Another one", 1));

      expect(task(state, activateTask("Save the world"))[1].active).toEqual(
        false
      );
    });
  });

  describe("deactivate task", () => {
    it("should change a task state to inactive", () => {
      const activeMockState = task(mockState, activateTask("Save the world"));

      expect(
        task(activeMockState, deactivateTask("Save the world"))[0].active
      ).toBe(false);
    });

    it("should do nothing to an inactive task", () => {
      expect(task(mockState, deactivateTask("Save the world"))).toEqual(
        mockState
      );
    });

    it("should not change anything about non-related tasks", () => {
      const state = task(mockState, addTask("Another one", 1));

      expect(task(state, deactivateTask("Save the world"))).toEqual(state);
    });
  });
});<commit_msg>Added a failing test case for functionality I forgot to add, so I remember on Monday<commit_after>import task from "../../app/reducers/task";
import {
  addTask,
  removeTask,
  completeTask,
  activateTask,
  deactivateTask
} from "../../app/actions/task";

describe("task", () => {
  const mockState = [
    {
      name: "Save the world",
      currentProgress: 0,
      totalPomodoros: 1,
      stopped: 0,
      active: false
    }
  ];

  it("should be defined", () => {
    expect(task).toBeDefined();
  });

  it("should handle initial state", () => {
    expect(task(undefined, [])).toMatchSnapshot();
  });

  describe("add task", () => {
    it("should add tasks", () => {
      expect(task([], addTask("Save the world", 1))).toEqual(mockState);
    });

    it("shouldn't add tasks that are already added", () => {
      //
      expect(task(mockState, addTask("Save the world", 100)).length).toEqual(1);
    });

    it("shouldn't override tasks that are already added", () => {
      //
      expect(task(mockState, addTask("Save the world", 100))).toEqual(
        mockState
      );
    });
  });

  describe("remove task", () => {
    it("should remove tasks", () => {
      expect(task(mockState, removeTask("Save the world")).length).toBe(0);
    });
  });

  describe("complete task", () => {
    it("should temporarily remove tasks", () => {
      expect(task(mockState, completeTask("Save the world")).length).toBe(0);
    });
  });

  describe("activate task", () => {
    it("should change a task state to active", () => {
      expect(task(mockState, activateTask("Save the world"))[0].active).toBe(
        true
      );
    });

    it("should do nothing to an active task", () => {
      const activeMockState = task(mockState, activateTask("Save the world"));

      expect(task(activeMockState, activateTask("Save the world"))).toEqual(
        activeMockState
      );
    });

    it("should not change anything about non-related tasks", () => {
      const state = task(mockState, addTask("Another one", 1));

      expect(task(state, activateTask("Save the world"))[1].active).toEqual(
        false
      );
    });
  });

  describe("deactivate task", () => {
    it("should change a task state to inactive", () => {
      const activeMockState = task(mockState, activateTask("Save the world"));

      expect(
        task(activeMockState, deactivateTask("Save the world"))[0].active
      ).toBe(false);
    });

    it("should change a task state to inactive", () => {
      const activeMockState = task(mockState, activateTask("Save the world"));

      expect(
        task(activeMockState, deactivateTask("Save the world"))[0].stopped
      ).toBe(1);
    });

    it("should do nothing to an inactive task", () => {
      expect(task(mockState, deactivateTask("Save the world"))).toEqual(
        mockState
      );
    });

    it("should not change anything about non-related tasks", () => {
      const state = task(mockState, addTask("Another one", 1));

      expect(task(state, deactivateTask("Save the world"))).toEqual(state);
    });
  });
});
{'fraction_non_alphanumeric': 0.17716333845366103, 'fraction_numerical': 0.0064857484212322925, 'mean_word_length': 2.9434724091520863, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4523594', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1699, 'n_words': 414}