<commit_before>const { assert } = require('chai')
const fixtures = require('../fixtures')
const Redux = require('redux')

const reducer = require('../../src/reducers/reducer')

describe('Tasks reducer', () => {
  it('has the correct default initial state', () => {
    const store = Redux.createStore(reducer)
    assert.deepEqual({ filters: [], tasks: [] }, store.getState())
  })

  describe('TASKS_SELECT', () => {
    it('selects specified task', () => {
      const now = new Date().toISOString()
      const initialTasks = [
        { id: 1, storageKey: 'issue-1', title: 'task', updatedAt: now },
        { id: 2, storageKey: 'pull-2', title: 'more task', updatedAt: now },
      ]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_SELECT', task: { storageKey: 'pull-2' } })

      const expectedTasks = [
        { id: 1, storageKey: 'issue-1', title: 'task', updatedAt: now },
        {
          id: 2,
          storageKey: 'pull-2',
          title: 'more task',
          updatedAt: now,
          isSelected: true,
        },
      ]

      assert.deepEqual(expectedTasks, store.getState().tasks)
    })
  })

  describe('TASKS_DESELECT', () => {
    it('deselects the specified task', () => {
      const now = new Date().toISOString()
      const initialTasks = [
        {
          id: 1,
          storageKey: 'issue-1',
          title: 'task',
          updatedAt: now,
          isSelected: true,
        },
        { id: 2, storageKey: 'pull-2', title: 'more task', updatedAt: now },
      ]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({
        type: 'TASKS_DESELECT',
        task: { storageKey: 'issue-1' },
      })

      const expectedTasks = [
        {
          id: 1,
          storageKey: 'issue-1',
          title: 'task',
          updatedAt: now,
          isSelected: false,
        },
        { id: 2, storageKey: 'pull-2', title: 'more task', updatedAt: now },
      ]

      assert.deepEqual(expectedTasks, store.getState().tasks)
    })
  })

  describe('TASKS_IGNORE', () => {
    it('ignores selected task', () => {
      const initialTasks = [
        { id: 5, storageKey: 'issue-5', isSelected: true },
        { id: 2, storageKey: 'pull-2' },
      ]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_IGNORE' })

      const expectedTasks = [
        {
          id: 5,
          storageKey: 'issue-5',
          isSelected: false,
          ignore: true,
          archivedAt: null,
          snoozedAt: null,
        },
        { id: 2, storageKey: 'pull-2' },
      ]

      assert.deepEqual(expectedTasks, store.getState().tasks)
    })
  })

  describe('TASKS_SNOOZE', () => {
    it('snoozes selected task', () => {
      const initialTasks = [
        { id: 15, storageKey: 'issue-15' },
        { id: 12, storageKey: 'pull-12', isSelected: true },
      ]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_SNOOZE' })

      const actual = store.getState().tasks
      assert.equal(2, actual.length, 'should still have 2 tasks')
      assert(!actual[1].isSelected, 'task should not be selected')
      assert.equal('string', typeof actual[1].snoozedAt,
                   'snoozedAt should be a time string')
    })
  })

  describe('TASKS_ARCHIVE', () => {
    it('archives the selected task', () => {<commit_msg>Update tests<commit_after>const { assert } = require('chai')
const fixtures = require('../fixtures')
const Redux = require('redux')

const reducer = require('../../src/reducers/reducer')

describe.only('Tasks reducer', () => {
  it('has the correct default initial state', () => {
    const store = Redux.createStore(reducer)
    assert.deepEqual({ filters: [], tasks: [] }, store.getState())
  })

  describe('TASKS_SELECT', () => {
    it('selects specified task', () => {
      const initialTasks = [fixtures.task, fixtures.anotherTask]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_SELECT', task: fixtures.task })

      const selectedTask = store.getState().tasks.find(task => task.isSelected)
      const unselectedTask = store.getState().tasks.find(task => !task.isSelected)
      assert.equal(selectedTask.storageKey, fixtures.task.storageKey)
      assert.equal(unselectedTask.storageKey, fixtures.anotherTask.storageKey)
    })
  })

  describe('TASKS_DESELECT', () => {
    it('deselects the specified task', () => {
      const selectedTask = Object.assign({}, fixtures.anotherTask, { isSelected: true })
      const initialTasks = [fixtures.task, selectedTask]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_DESELECT', task: selectedTask })

      const updatedSelectedTask = store.getState().tasks.find(task => task.isSelected)
      assert.equal(updatedSelectedTask, null)
    })
  })

  describe('TASKS_IGNORE', () => {
    it('ignores selected task', () => {
      const initialTasks = [fixtures.task, fixtures.anotherTask]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_SELECT', task: fixtures.task })
      store.dispatch({ type: 'TASKS_IGNORE' })

      const ignoredTask = store.getState().tasks.find(t => t.ignore)
      const task = store.getState().tasks.find(t => !t.ignore)
      assert.equal(ignoredTask.storageKey, fixtures.task.storageKey)
      assert.equal(task.storageKey, fixtures.anotherTask.storageKey)
    })
  })

  describe('TASKS_SNOOZE', () => {
    it('snoozes selected task', () => {
      const initialTasks = [
        { id: 15, storageKey: 'issue-15' },
        { id: 12, storageKey: 'pull-12', isSelected: true },
      ]

      const store = Redux.createStore(reducer, { tasks: initialTasks })
      store.dispatch({ type: 'TASKS_SNOOZE' })

      const actual = store.getState().tasks
      assert.equal(2, actual.length, 'should still have 2 tasks')
      assert(!actual[1].isSelected, 'task should not be selected')
      assert.equal('string', typeof actual[1].snoozedAt,
                   'snoozedAt should be a time string')
    })
  })

  describe('TASKS_ARCHIVE', () => {
    it('archives the selected task', () => {
{'fraction_non_alphanumeric': 0.15546813532651454, 'fraction_numerical': 0.007867820613690008, 'mean_word_length': 2.6570771001150746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, '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': '2743592', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1936, 'n_words': 426}