actions.test.ts 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import { ActionTypes } from 'app/containers/Schedule/constants'
  21. import actions from 'app/containers/Schedule/actions'
  22. import { mockStore } from './fixtures'
  23. describe('Schedule Actions', () => {
  24. const {
  25. schedule,
  26. projectId,
  27. mails,
  28. schedules,
  29. scheduleId,
  30. resolve,
  31. jobType
  32. } = mockStore
  33. describe('loadSchedules', () => {
  34. it('loadSchedules should return the correct type', () => {
  35. const expectedResult = {
  36. type: ActionTypes.LOAD_SCHEDULES,
  37. payload: {
  38. projectId
  39. }
  40. }
  41. expect(actions.loadSchedules(projectId)).toEqual(expectedResult)
  42. })
  43. })
  44. describe('schedulesLoaded', () => {
  45. it('schedulesLoaded should return the correct type', () => {
  46. const expectedResult = {
  47. type: ActionTypes.LOAD_SCHEDULES_SUCCESS,
  48. payload: {
  49. schedules
  50. }
  51. }
  52. expect(actions.schedulesLoaded(schedules)).toEqual(expectedResult)
  53. })
  54. })
  55. describe('loadSchedulesFail', () => {
  56. it('loadSchedulesFail should return the correct type', () => {
  57. const expectedResult = {
  58. type: ActionTypes.LOAD_SCHEDULES_FAILURE,
  59. payload: {}
  60. }
  61. expect(actions.loadSchedulesFail()).toEqual(expectedResult)
  62. })
  63. })
  64. describe('loadScheduleDetail', () => {
  65. it('loadScheduleDetail should return the correct type', () => {
  66. const expectedResult = {
  67. type: ActionTypes.LOAD_SCHEDULE_DETAIL,
  68. payload: {
  69. scheduleId
  70. }
  71. }
  72. expect(actions.loadScheduleDetail(scheduleId)).toEqual(expectedResult)
  73. })
  74. })
  75. describe('scheduleDetailLoaded', () => {
  76. it('scheduleDetailLoaded should return the correct type', () => {
  77. const expectedResult = {
  78. type: ActionTypes.LOAD_SCHEDULE_DETAIL_SUCCESS,
  79. payload: {
  80. schedule
  81. }
  82. }
  83. expect(actions.scheduleDetailLoaded(schedule)).toEqual(expectedResult)
  84. })
  85. })
  86. describe('loadScheduleDetailFail', () => {
  87. it('loadScheduleDetailFail should return the correct type', () => {
  88. const expectedResult = {
  89. type: ActionTypes.LOAD_SCHEDULE_DETAIL_FAILURE,
  90. payload: {}
  91. }
  92. expect(actions.loadScheduleDetailFail()).toEqual(expectedResult)
  93. })
  94. })
  95. describe('addSchedule', () => {
  96. it('addSchedule should return the correct type', () => {
  97. const expectedResult = {
  98. type: ActionTypes.ADD_SCHEDULE,
  99. payload: {
  100. schedule,
  101. resolve
  102. }
  103. }
  104. expect(actions.addSchedule(schedule, resolve)).toEqual(expectedResult)
  105. })
  106. })
  107. describe('scheduleAdded', () => {
  108. it('scheduleAdded should return the correct type', () => {
  109. const expectedResult = {
  110. type: ActionTypes.ADD_SCHEDULE_SUCCESS,
  111. payload: {
  112. result: schedule
  113. }
  114. }
  115. expect(actions.scheduleAdded(schedule)).toEqual(expectedResult)
  116. })
  117. })
  118. describe('addScheduleFail', () => {
  119. it('addScheduleFail should return the correct type', () => {
  120. const expectedResult = {
  121. type: ActionTypes.ADD_SCHEDULE_FAILURE,
  122. payload: {}
  123. }
  124. expect(actions.addScheduleFail()).toEqual(expectedResult)
  125. })
  126. })
  127. describe('editSchedule', () => {
  128. it('editSchedule should return the correct type', () => {
  129. const expectedResult = {
  130. type: ActionTypes.EDIT_SCHEDULE,
  131. payload: {
  132. schedule,
  133. resolve
  134. }
  135. }
  136. expect(actions.editSchedule(schedule, resolve)).toEqual(expectedResult)
  137. })
  138. })
  139. describe('scheduleEdited', () => {
  140. it('scheduleEdited should return the correct type', () => {
  141. const expectedResult = {
  142. type: ActionTypes.EDIT_SCHEDULE_SUCCESS,
  143. payload: {
  144. result: schedule
  145. }
  146. }
  147. expect(actions.scheduleEdited(schedule)).toEqual(expectedResult)
  148. })
  149. })
  150. describe('editScheduleFail', () => {
  151. it('editScheduleFail should return the correct type', () => {
  152. const expectedResult = {
  153. type: ActionTypes.EDIT_SCHEDULE_FAILURE,
  154. payload: {}
  155. }
  156. expect(actions.editScheduleFail()).toEqual(expectedResult)
  157. })
  158. })
  159. describe('deleteSchedule', () => {
  160. it('deleteSchedule should return the correct type', () => {
  161. const expectedResult = {
  162. type: ActionTypes.DELETE_SCHEDULE,
  163. payload: {
  164. id: scheduleId
  165. }
  166. }
  167. expect(actions.deleteSchedule(scheduleId)).toEqual(expectedResult)
  168. })
  169. })
  170. describe('scheduleDeleted', () => {
  171. it('scheduleDeleted should return the correct type', () => {
  172. const expectedResult = {
  173. type: ActionTypes.DELETE_SCHEDULE_SUCCESS,
  174. payload: {
  175. id: scheduleId
  176. }
  177. }
  178. expect(actions.scheduleDeleted(scheduleId)).toEqual(expectedResult)
  179. })
  180. })
  181. describe('deleteScheduleFail', () => {
  182. it('deleteScheduleFail should return the correct type', () => {
  183. const expectedResult = {
  184. type: ActionTypes.DELETE_SCHEDULE_FAILURE,
  185. payload: {}
  186. }
  187. expect(actions.deleteScheduleFail()).toEqual(expectedResult)
  188. })
  189. })
  190. describe('changeSchedulesStatus', () => {
  191. it('changeSchedulesStatus should return the correct type', () => {
  192. const expectedResult = {
  193. type: ActionTypes.CHANGE_SCHEDULE_STATUS,
  194. payload: {
  195. id: scheduleId,
  196. currentStatus: 'new'
  197. }
  198. }
  199. expect(actions.changeSchedulesStatus(scheduleId, 'new')).toEqual(
  200. expectedResult
  201. )
  202. })
  203. })
  204. describe('scheduleStatusChanged', () => {
  205. it('scheduleStatusChanged should return the correct type', () => {
  206. const expectedResult = {
  207. type: ActionTypes.CHANGE_SCHEDULE_STATUS_SUCCESS,
  208. payload: {
  209. schedule
  210. }
  211. }
  212. expect(actions.scheduleStatusChanged(schedule)).toEqual(expectedResult)
  213. })
  214. })
  215. describe('changeScheduleJobType', () => {
  216. it('changeScheduleJobType should return the correct type', () => {
  217. const expectedResult = {
  218. type: ActionTypes.CHANGE_SCHEDULE_JOB_TYPE,
  219. payload: {
  220. jobType
  221. }
  222. }
  223. expect(actions.changeScheduleJobType(jobType)).toEqual(expectedResult)
  224. })
  225. })
  226. describe('changeSchedulesStatusFail', () => {
  227. it('changeSchedulesStatusFail should return the correct type', () => {
  228. const expectedResult = {
  229. type: ActionTypes.CHANGE_SCHEDULE_STATUS_FAILURE,
  230. payload: {}
  231. }
  232. expect(actions.changeSchedulesStatusFail()).toEqual(expectedResult)
  233. })
  234. })
  235. describe('executeScheduleImmediately', () => {
  236. it('executeScheduleImmediately should return the correct type', () => {
  237. const expectedResult = {
  238. type: ActionTypes.EXECUTE_SCHEDULE_IMMEDIATELY,
  239. payload: {
  240. id: scheduleId,
  241. resolve
  242. }
  243. }
  244. expect(actions.executeScheduleImmediately(scheduleId, resolve)).toEqual(
  245. expectedResult
  246. )
  247. })
  248. })
  249. describe('resetScheduleState', () => {
  250. it('resetScheduleState should return the correct type', () => {
  251. const expectedResult = {
  252. type: ActionTypes.RESET_SCHEDULE_STATE,
  253. payload: {}
  254. }
  255. expect(actions.resetScheduleState()).toEqual(expectedResult)
  256. })
  257. })
  258. describe('loadSuggestMails', () => {
  259. it('loadSuggestMails should return the correct type', () => {
  260. const expectedResult = {
  261. type: ActionTypes.LOAD_SUGGEST_MAILS,
  262. payload: {
  263. keyword: ''
  264. }
  265. }
  266. expect(actions.loadSuggestMails('')).toEqual(expectedResult)
  267. })
  268. })
  269. describe('suggestMailsLoaded', () => {
  270. it('suggestMailsLoaded should return the correct type', () => {
  271. const expectedResult = {
  272. type: ActionTypes.LOAD_SUGGEST_MAILS_SUCCESS,
  273. payload: {
  274. mails
  275. }
  276. }
  277. expect(actions.suggestMailsLoaded(mails)).toEqual(expectedResult)
  278. })
  279. })
  280. describe('loadSuggestMailsFail', () => {
  281. it('loadSuggestMailsFail should return the correct type', () => {
  282. const expectedResult = {
  283. type: ActionTypes.LOAD_SUGGEST_MAILS_FAILURE,
  284. payload: {}
  285. }
  286. expect(actions.loadSuggestMailsFail()).toEqual(expectedResult)
  287. })
  288. })
  289. describe('portalDashboardsLoaded', () => {
  290. it('portalDashboardsLoaded should return the correct type', () => {
  291. const expectedResult = {
  292. type: ActionTypes.LOAD_PORTAL_DASHBOARDS_SUCCESS,
  293. payload: {
  294. portalId: scheduleId,
  295. dashboards: []
  296. }
  297. }
  298. expect(actions.portalDashboardsLoaded(scheduleId, [])).toEqual(
  299. expectedResult
  300. )
  301. })
  302. })
  303. describe('loadVizs', () => {
  304. it('loadVizs should return the correct type', () => {
  305. const expectedResult = {
  306. type: ActionTypes.LOAD_VIZS,
  307. payload: {
  308. projectId: scheduleId
  309. }
  310. }
  311. expect(actions.loadVizs(scheduleId)).toEqual(expectedResult)
  312. })
  313. })
  314. describe('vizsLoaded', () => {
  315. it('vizsLoaded should return the correct type', () => {
  316. const expectedResult = {
  317. type: ActionTypes.LOAD_VIZS_SUCCESS,
  318. payload: {
  319. result: schedule
  320. }
  321. }
  322. expect(actions.vizsLoaded(schedule)).toEqual(expectedResult)
  323. })
  324. })
  325. describe('loadVizsFail', () => {
  326. it('loadVizsFail should return the correct type', () => {
  327. const expectedResult = { type: ActionTypes.LOAD_VIZS_FAILUER }
  328. expect(actions.loadVizsFail()).toEqual(expectedResult)
  329. })
  330. })
  331. })