{"size": 1651, "ext": "js", "max_stars_repo_path": "spec/join-action-group/actionGroupSelectedInUrlNotFoundSpec.js", "max_stars_repo_name": "fsakita/manchester-charter", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "spec/join-action-group/actionGroupSelectedInUrlNotFoundSpec.js", "max_issues_repo_name": "fsakita/manchester-charter", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "spec/join-action-group/actionGroupSelectedInUrlNotFoundSpec.js", "max_forks_repo_name": "fsakita/manchester-charter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.0655737705, "max_line_length": 72, "alphanum_fraction": 0.6365838886}
/*
  global describe, beforeEach, afterEach, it, expect
*/
'use strict'

let Model = require('../../src/js/JoinActionGroup')
var sinon = require('sinon')
var validation = require('../../src/js/validation')
var api = require('../../src/js/api-endpoints')
var ajax = require('../../src/js/ajax')
var querystring = require('../../src/js/getUrlParam')
var browser = require('../../src/js/browser')
import { getGroupData } from './getGroupData'

describe('Action Group selected in url not found', () => {
  var sut
  let browserRedirectStub = null

  beforeEach(() => {
    sinon.stub(browser, 'loading')
    sinon.stub(browser, 'loaded')
    sinon.stub(browser, 'setOnHistoryPop')
    sinon.stub(browser, 'pushHistory')
    browserRedirectStub = sinon.stub(browser, 'redirect')
    sinon.stub(validation, 'initialise')
    sinon.stub(validation, 'getValidationGroup')

    sinon.stub(querystring, 'hashbang')
      .returns('invalid-group')

    sinon.stub(ajax, 'get')
      .withArgs(api.actionGroups)
      .returns({
        then: function (success, error) {
          success({
            'status': 'ok',
            'data': getGroupData()
          })
        }
      })

    sut = new Model()
  })

  afterEach(() => {
    browser.loading.restore()
    browser.loaded.restore()
    browser.pushHistory.restore()
    browser.setOnHistoryPop.restore()
    browser.redirect.restore()
    querystring.hashbang.restore()
    validation.initialise.restore()
    validation.getValidationGroup.restore()
    ajax.get.restore()
  })

  it('- Should redirect to 404', () => {
    expect(browserRedirectStub.withArgs('/404').calledOnce).toBeTruthy()
  })
})
