{"size": 1521, "ext": "js", "max_stars_repo_path": "src/event/__tests__/application.spec.js", "max_stars_repo_name": "coord-e/lottery-frontend", "max_stars_repo_stars_event_min_datetime": "2020-06-28T07:05:08.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-28T07:05:08.000Z", "max_issues_repo_path": "src/event/__tests__/application.spec.js", "max_issues_repo_name": "coord-e/lottery-frontend", "max_issues_repo_issues_event_min_datetime": "2018-06-23T07:44:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T22:40:30.000Z", "max_forks_repo_path": "src/event/__tests__/application.spec.js", "max_forks_repo_name": "Sakuten/lottery-frontend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 131, "max_forks_count": null, "avg_line_length": 31.0408163265, "max_line_length": 86, "alphanum_fraction": 0.6502301118}
import { ApplicationObject } from '../application'
import { Store } from '../../store'

describe('events', () => {
  describe('ApplicationObject', () => {
    let event

    beforeEach(() => {
      event = new ApplicationObject(new Store())
    })

    it('fetches lists in constructor', () => {
      expect(event.store.application.classroomList.length).not.toBe(0)
      expect(event.store.application.lotteryList.length).not.toBe(0)
    })

    it('changes classroom', () => {
      event.onChangeClassroom(2)
      expect(event.store.application.classroom).toBe(2)
    })

    it('changes lottery', () => {
      event.onChangeLottery(2)
      expect(event.store.application.lottery).toBe(2)
    })

    it('adds a group member', async () => {
      await event.onAddGroupMember('secret_id')
      expect(event.store.application.groupMemberList).toEqual([['secret_id', 'ABCD']])
    })

    it('can\'t add group member when there is already 3', async () => {
      await event.onAddGroupMember('secret_id1')
      await event.onAddGroupMember('secret_id2')
      await event.onAddGroupMember('secret_id3')

      await event.onAddGroupMember('secret_id4')
      expect(event.store.error.errorList).toHaveLength(1)
      expect(event.store.application.groupMemberList).toHaveLength(3)
    })

    it('removes a group member', async () => {
      await event.onAddGroupMember('secret_id', 'public_id')
      event.onRemoveGroupMember(0)
      expect(event.store.application.groupMemberList).toEqual([])
    })
  })
})
