{"size": 1597, "ext": "js", "max_stars_repo_path": "test/components/Timeline/Playbook/DisplayGlobalActionsTest.js", "max_stars_repo_name": "danieljurek/Sia-EventUI", "max_stars_repo_stars_event_min_datetime": "2018-01-01T07:06:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-01T14:54:31.000Z", "max_issues_repo_path": "test/components/Timeline/Playbook/DisplayGlobalActionsTest.js", "max_issues_repo_name": "danieljurek/Sia-EventUI", "max_issues_repo_issues_event_min_datetime": "2017-11-13T23:40:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-23T19:58:52.000Z", "max_forks_repo_path": "test/components/Timeline/Playbook/DisplayGlobalActionsTest.js", "max_forks_repo_name": "danieljurek/Sia-EventUI", "max_forks_repo_forks_event_min_datetime": "2017-11-13T17:16:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-10T10:28:48.000Z"}
{"max_stars_count": 4, "max_issues_count": 87, "max_forks_count": 9, "avg_line_length": 25.7580645161, "max_line_length": 103, "alphanum_fraction": 0.4758922981}
'use strict'
import { expect } from 'chai'

import {
  mapStateToDisplayGlobalActionsProps
} from 'components/Timeline/Playbook/DisplayGlobalActions'

describe('DisplayGlobalActions', function () {
  describe('mapStateToProps', function () {
    const ownProps = {
      ticketId: 7,
      incidentId: 1
    }

    describe('Qualified Actions', function () {
      const state = {
        tickets: {
          map: {
            7: {
              id: 7
            }
          }
        },
        globalActions: {
          1: {
            name: 'ExpectedAction',
            conditionSets: []
          },
          2: {
            name: 'OtherAction',
            conditionSets: [
              {
                type: 1,
                conditions: [
                  {
                    conditionSource: {
                      name: 'testSource',
                      sourceObject: 1,
                      key: 'the key that will not be matched'
                    },
                    assertionType: 0,
                    conditionType: 2,
                    dataFormat: 0
                  }
                ]
              }
            ]
          }
        }
      }

      it('Should test actions and return qualified actions based on state.globalActions', function () {
        const result = mapStateToDisplayGlobalActionsProps(state, ownProps)
        const expectedNumberOfQualifyingActions = 1

        expect(result.actions[0].name).to.equal('ExpectedAction')
        expect(result.actions.length).to.equal(expectedNumberOfQualifyingActions)
      })
    })
  })
})
