actions.test.ts 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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/Display/constants'
  21. import actions from 'app/containers/Display/actions'
  22. import {
  23. mockDisplayId,
  24. mockSlideId,
  25. mockGraphLayerFormed,
  26. mockWidgetFormed,
  27. mockFormedViews,
  28. mockHttpError,
  29. mockCover,
  30. mockSlide,
  31. mockSlideCoverUploadImgSrc,
  32. mockSlideSize,
  33. mockLayerScale,
  34. mockGraphLayerId,
  35. mockDeltaSize,
  36. mockFinish,
  37. mockDeltaPosition,
  38. mockEventTrigger,
  39. mockOperation,
  40. mockAlignmentType,
  41. mockSelected,
  42. mockExclusive,
  43. mockChangedOperationInfo,
  44. mockBaseLines,
  45. mockLayerParamsUnChanged,
  46. mockChangedParams,
  47. mockShareLinkParams,
  48. mockShareToken,
  49. mockAuthShareToken,
  50. mockPasswordToken,
  51. mockPassword,
  52. mockDisplayTitle
  53. } from './fixtures'
  54. describe('Display Actions', () => {
  55. describe('loadSlideDetail', () => {
  56. it('should return the correct type and passed displayId', () => {
  57. const expectedResult = {
  58. type: ActionTypes.LOAD_SLIDE_DETAIL,
  59. payload: {
  60. displayId: mockDisplayId,
  61. slideId: mockSlideId
  62. }
  63. }
  64. expect(actions.loadSlideDetail(mockDisplayId, mockSlideId)).toEqual(
  65. expectedResult
  66. )
  67. })
  68. })
  69. describe('slideDetailLoaded', () => {
  70. it('should return the correct type', () => {
  71. const expectedResult = {
  72. type: ActionTypes.LOAD_SLIDE_DETAIL_SUCCESS,
  73. payload: {
  74. slideId: mockSlideId,
  75. layers: [mockGraphLayerFormed],
  76. widgets: [mockWidgetFormed],
  77. formedViews: mockFormedViews
  78. }
  79. }
  80. expect(
  81. actions.slideDetailLoaded(
  82. mockSlideId,
  83. [mockGraphLayerFormed],
  84. [mockWidgetFormed],
  85. mockFormedViews
  86. )
  87. ).toEqual(expectedResult)
  88. })
  89. })
  90. describe('loadSlideDetailFail', () => {
  91. it('should return the correct type and error', () => {
  92. const expectedResult = {
  93. type: ActionTypes.LOAD_SLIDE_DETAIL_FAILURE,
  94. payload: {
  95. err: mockHttpError
  96. }
  97. }
  98. expect(actions.loadSlideDetailFail(mockHttpError)).toEqual(expectedResult)
  99. })
  100. })
  101. describe('uploadCurrentSlideCover', () => {
  102. it('should return the correct type and right cover, slide', () => {
  103. const expectedResult = {
  104. type: ActionTypes.UPLOAD_CURRENT_SLIDE_COVER,
  105. payload: {
  106. cover: mockCover,
  107. slide: mockSlide
  108. }
  109. }
  110. expect(actions.uploadCurrentSlideCover(mockCover, mockSlide)).toEqual(
  111. expectedResult
  112. )
  113. })
  114. })
  115. describe('currentSlideCoverUploaded', () => {
  116. it('should return the correct type and passed result', () => {
  117. const expectedResult = {
  118. type: ActionTypes.UPLOAD_CURRENT_SLIDE_COVER_SUCCESS,
  119. payload: {
  120. result: mockSlideCoverUploadImgSrc
  121. }
  122. }
  123. expect(
  124. actions.currentSlideCoverUploaded(mockSlideCoverUploadImgSrc)
  125. ).toEqual(expectedResult)
  126. })
  127. })
  128. describe('uploadCurrentSlideCoverFail', () => {
  129. it('should return the correct type and throw err', () => {
  130. const expectedResult = {
  131. type: ActionTypes.UPLOAD_CURRENT_SLIDE_COVER_FAILURE,
  132. payload: {
  133. error: mockHttpError
  134. }
  135. }
  136. expect(actions.uploadCurrentSlideCoverFail(mockHttpError)).toEqual(
  137. expectedResult
  138. )
  139. })
  140. })
  141. describe('resizeLayer', () => {
  142. it('should return the correct type and resize params', () => {
  143. const expectedResult = {
  144. type: ActionTypes.RESIZE_LAYER,
  145. payload: {
  146. slideSize: mockSlideSize,
  147. scale: mockLayerScale,
  148. layerId: mockGraphLayerId,
  149. deltaSize: mockDeltaSize,
  150. finish: mockFinish
  151. }
  152. }
  153. expect(
  154. actions.resizeLayer(
  155. mockSlideSize,
  156. mockLayerScale,
  157. mockGraphLayerId,
  158. mockDeltaSize,
  159. mockFinish
  160. )
  161. ).toEqual(expectedResult)
  162. })
  163. })
  164. describe('resizeLayerAdjusted', () => {
  165. it('should return the correct type and passed deltaSize', () => {
  166. const expectedResult = {
  167. type: ActionTypes.RESIZE_LAYER_ADJUSTED,
  168. payload: {
  169. layerIds: [mockGraphLayerId],
  170. deltaSize: mockDeltaSize,
  171. finish: mockFinish
  172. }
  173. }
  174. expect(
  175. actions.resizeLayerAdjusted([mockGraphLayerId], mockDeltaSize, mockFinish)
  176. ).toEqual(expectedResult)
  177. })
  178. })
  179. describe('dragLayer', () => {
  180. it('should return the correct type and drag params', () => {
  181. const expectedResult = {
  182. type: ActionTypes.DRAG_LAYER,
  183. payload: {
  184. slideSize: mockSlideSize,
  185. scale: mockLayerScale,
  186. layerId: mockGraphLayerId,
  187. deltaPosition: mockDeltaPosition,
  188. eventTrigger: mockEventTrigger,
  189. finish: mockFinish
  190. }
  191. }
  192. expect(
  193. actions.dragLayer(
  194. mockSlideSize,
  195. mockLayerScale,
  196. mockDeltaPosition,
  197. mockEventTrigger,
  198. mockFinish,
  199. mockGraphLayerId
  200. )
  201. ).toEqual(expectedResult)
  202. })
  203. })
  204. describe('dragLayerAdjusted', () => {
  205. it('should return the correct type and drag params', () => {
  206. const expectedResult = {
  207. type: ActionTypes.DRAG_LAYER_ADJUSTED,
  208. payload: {
  209. layerIds: [mockGraphLayerId],
  210. slideSize: mockSlideSize,
  211. deltaPosition: mockDeltaPosition,
  212. finish: mockFinish
  213. }
  214. }
  215. expect(
  216. actions.dragLayerAdjusted(
  217. [mockGraphLayerId],
  218. mockSlideSize,
  219. mockDeltaPosition,
  220. mockFinish
  221. )
  222. ).toEqual(expectedResult)
  223. })
  224. })
  225. describe('changeLayersStack', () => {
  226. it('should return the correct type and passed operation', () => {
  227. const expectedResult = {
  228. type: ActionTypes.CHANGE_LAYERS_STACK,
  229. payload: {
  230. operation: mockOperation
  231. }
  232. }
  233. expect(actions.changeLayersStack(mockOperation)).toEqual(expectedResult)
  234. })
  235. })
  236. describe('setLayersAlignment', () => {
  237. it('should return the correct type and passed alignmentType', () => {
  238. const expectedResult = {
  239. type: ActionTypes.SET_LAYERS_ALIGNMENT,
  240. payload: {
  241. alignmentType: mockAlignmentType
  242. }
  243. }
  244. expect(actions.setLayersAlignment(mockAlignmentType)).toEqual(
  245. expectedResult
  246. )
  247. })
  248. })
  249. describe('selectLayer', () => {
  250. it('should return the correct type and passed layer status', () => {
  251. const expectedResult = {
  252. type: ActionTypes.SELECT_LAYER,
  253. payload: {
  254. layerId: mockGraphLayerId,
  255. selected: mockSelected,
  256. exclusive: mockExclusive
  257. }
  258. }
  259. expect(
  260. actions.selectLayer(mockGraphLayerId, mockSelected, mockExclusive)
  261. ).toEqual(expectedResult)
  262. })
  263. })
  264. describe('clearLayersOperationInfo', () => {
  265. it('should return the correct type and passed changedInfo', () => {
  266. const expectedResult = {
  267. type: ActionTypes.CLEAR_LAYERS_OPERATION_INFO,
  268. payload: {
  269. changedInfo: mockChangedOperationInfo
  270. }
  271. }
  272. expect(actions.clearLayersOperationInfo(mockChangedOperationInfo)).toEqual(
  273. expectedResult
  274. )
  275. })
  276. })
  277. describe('clearEditorBaselines', () => {
  278. it('should return the correct type', () => {
  279. const expectedResult = {
  280. type: ActionTypes.CLEAR_EDITOR_BASELINES,
  281. payload: {}
  282. }
  283. expect(actions.clearEditorBaselines()).toEqual(expectedResult)
  284. })
  285. })
  286. describe('showEditorBaselines', () => {
  287. it('should return the correct type and baselines', () => {
  288. const expectedResult = {
  289. type: ActionTypes.SHOW_EDITOR_BASELINES,
  290. payload: {
  291. baselines: [mockBaseLines]
  292. }
  293. }
  294. expect(actions.showEditorBaselines([mockBaseLines])).toEqual(expectedResult)
  295. })
  296. })
  297. describe('copySlideLayers', () => {
  298. it('should return the correct type', () => {
  299. const expectedResult = {
  300. type: ActionTypes.COPY_SLIDE_LAYERS,
  301. payload: {}
  302. }
  303. expect(actions.copySlideLayers()).toEqual(expectedResult)
  304. })
  305. })
  306. describe('slideLayersCopied', () => {
  307. it('should return the correct type and layer', () => {
  308. const expectedResult = {
  309. type: ActionTypes.COPY_SLIDE_LAYERS_SUCCESS,
  310. payload: {
  311. layers: [mockGraphLayerFormed]
  312. }
  313. }
  314. expect(actions.slideLayersCopied([mockGraphLayerFormed])).toEqual(expectedResult)
  315. })
  316. })
  317. describe('pasteSlideLayers', () => {
  318. it('should return the correct type', () => {
  319. const expectedResult = {
  320. type: ActionTypes.PASTE_SLIDE_LAYERS,
  321. payload: {}
  322. }
  323. expect(actions.pasteSlideLayers()).toEqual(expectedResult)
  324. })
  325. })
  326. describe('addSlideLayers', () => {
  327. it('should return the correct type', () => {
  328. const expectedResult = {
  329. type: ActionTypes.ADD_SLIDE_LAYERS,
  330. payload: {
  331. displayId: mockDisplayId,
  332. slideId: mockSlideId,
  333. layers: [mockGraphLayerFormed],
  334. widgets: [mockWidgetFormed]
  335. }
  336. }
  337. expect(
  338. actions.addSlideLayers(
  339. mockDisplayId,
  340. mockSlideId,
  341. [mockGraphLayerFormed],
  342. [mockWidgetFormed]
  343. )
  344. ).toEqual(expectedResult)
  345. })
  346. })
  347. describe('slideLayersAdded', () => {
  348. it('should return the correct type', () => {
  349. const expectedResult = {
  350. type: ActionTypes.ADD_SLIDE_LAYERS_SUCCESS,
  351. payload: {
  352. slideId: mockSlideId,
  353. layers: [mockGraphLayerFormed],
  354. widgets: [mockWidgetFormed]
  355. }
  356. }
  357. expect(
  358. actions.slideLayersAdded(mockSlideId, [mockGraphLayerFormed], [mockWidgetFormed])
  359. ).toEqual(expectedResult)
  360. })
  361. })
  362. describe('addSlideLayersFail', () => {
  363. it('should return the correct type', () => {
  364. const expectedResult = {
  365. type: ActionTypes.ADD_SLIDE_LAYERS_FAILURE,
  366. payload: {}
  367. }
  368. expect(actions.addSlideLayersFail()).toEqual(expectedResult)
  369. })
  370. })
  371. describe('editSlideLayers', () => {
  372. it('should return the correct type', () => {
  373. const expectedResult = {
  374. type: ActionTypes.EDIT_SLIDE_LAYERS,
  375. payload: {
  376. displayId: mockDisplayId,
  377. slideId: mockSlideId,
  378. layers: [mockGraphLayerFormed],
  379. layerParamsUnChanged: mockLayerParamsUnChanged
  380. }
  381. }
  382. expect(
  383. actions.editSlideLayers(
  384. mockDisplayId,
  385. mockSlideId,
  386. [mockGraphLayerFormed],
  387. mockLayerParamsUnChanged
  388. )
  389. ).toEqual(expectedResult)
  390. })
  391. })
  392. describe('slideLayersEdited', () => {
  393. it('should return the correct type', () => {
  394. const expectedResult = {
  395. type: ActionTypes.EDIT_SLIDE_LAYERS_SUCCESS,
  396. payload: {
  397. slideId: mockSlideId,
  398. layers: [mockGraphLayerFormed]
  399. }
  400. }
  401. expect(actions.slideLayersEdited(mockSlideId, [mockGraphLayerFormed])).toEqual(
  402. expectedResult
  403. )
  404. })
  405. })
  406. describe('editSlideLayersFail', () => {
  407. it('should return the correct type', () => {
  408. const expectedResult = {
  409. type: ActionTypes.EDIT_SLIDE_LAYERS_FAILURE,
  410. payload: {}
  411. }
  412. expect(actions.editSlideLayersFail()).toEqual(expectedResult)
  413. })
  414. })
  415. describe('editSlideLayerParams', () => {
  416. it('should return the correct type', () => {
  417. const expectedResult = {
  418. type: ActionTypes.EDIT_SLIDE_LAYER_PARAMS,
  419. payload: {
  420. layerId: mockGraphLayerId,
  421. changedParams: mockChangedParams
  422. }
  423. }
  424. expect(
  425. actions.editSlideLayerParams(mockGraphLayerId, mockChangedParams)
  426. ).toEqual(expectedResult)
  427. })
  428. })
  429. describe('deleteSlideLayers', () => {
  430. it('should return the correct type', () => {
  431. const expectedResult = {
  432. type: ActionTypes.DELETE_SLIDE_LAYERS,
  433. payload: {
  434. displayId: mockDisplayId,
  435. slideId: mockSlideId
  436. }
  437. }
  438. expect(actions.deleteSlideLayers(mockDisplayId, mockSlideId)).toEqual(
  439. expectedResult
  440. )
  441. })
  442. })
  443. describe('changeLayerOperationInfo', () => {
  444. it('should return the correct type', () => {
  445. const expectedResult = {
  446. type: ActionTypes.CHANGE_LAYER_OPERATION_INFO,
  447. payload: {
  448. layerId: mockGraphLayerId,
  449. changedInfo: mockChangedOperationInfo
  450. }
  451. }
  452. expect(
  453. actions.changeLayerOperationInfo(mockGraphLayerId, mockChangedOperationInfo)
  454. ).toEqual(expectedResult)
  455. })
  456. })
  457. describe('slideLayersDeleted', () => {
  458. it('should return the correct type', () => {
  459. const expectedResult = {
  460. type: ActionTypes.DELETE_SLIDE_LAYERS_SUCCESS,
  461. payload: {
  462. slideId: mockSlideId,
  463. layerIds: [mockGraphLayerId]
  464. }
  465. }
  466. expect(actions.slideLayersDeleted(mockSlideId, [mockGraphLayerId])).toEqual(
  467. expectedResult
  468. )
  469. })
  470. })
  471. describe('deleteSlideLayersFail', () => {
  472. it('should return the correct type', () => {
  473. const expectedResult = {
  474. type: ActionTypes.DELETE_SLIDE_LAYERS_FAILURE,
  475. payload: {}
  476. }
  477. expect(actions.deleteSlideLayersFail()).toEqual(expectedResult)
  478. })
  479. })
  480. describe('loadDisplayShareLink', () => {
  481. it('should return the correct type', () => {
  482. const expectedResult = {
  483. type: ActionTypes.LOAD_DISPLAY_SHARE_LINK,
  484. payload: {
  485. params: mockShareLinkParams
  486. }
  487. }
  488. expect(actions.loadDisplayShareLink(mockShareLinkParams)).toEqual(
  489. expectedResult
  490. )
  491. })
  492. })
  493. describe('displayShareLinkLoaded', () => {
  494. it('should return the correct type', () => {
  495. const expectedResult = {
  496. type: ActionTypes.LOAD_DISPLAY_SHARE_LINK_SUCCESS,
  497. payload: {
  498. shareToken: mockShareToken
  499. }
  500. }
  501. expect(actions.displayShareLinkLoaded(mockShareToken)).toEqual(
  502. expectedResult
  503. )
  504. })
  505. })
  506. describe('displayAuthorizedShareLinkLoaded', () => {
  507. it('should return the correct type', () => {
  508. const expectedResult = {
  509. type: ActionTypes.LOAD_DISPLAY_AUTHORIZED_SHARE_LINK_SUCCESS,
  510. payload: {
  511. authorizedShareToken: mockAuthShareToken
  512. }
  513. }
  514. expect(
  515. actions.displayAuthorizedShareLinkLoaded(mockAuthShareToken)
  516. ).toEqual(expectedResult)
  517. })
  518. })
  519. describe('displayPasswordShareLinkLoaded', () => {
  520. it('should return the correct type', () => {
  521. const expectedResult = {
  522. type: ActionTypes.LOAD_DISPLAY_PASSWORD_SHARE_LINK_SUCCESS,
  523. payload: {
  524. passwordShareToken: mockPasswordToken,
  525. password: mockPassword
  526. }
  527. }
  528. expect(
  529. actions.displayPasswordShareLinkLoaded(mockPasswordToken, mockPassword)
  530. ).toEqual(expectedResult)
  531. })
  532. })
  533. describe('loadDisplayShareLinkFail', () => {
  534. it('should return the correct type', () => {
  535. const expectedResult = {
  536. type: ActionTypes.LOAD_DISPLAY_SHARE_LINK_FAILURE,
  537. payload: {}
  538. }
  539. expect(actions.loadDisplayShareLinkFail()).toEqual(expectedResult)
  540. })
  541. })
  542. describe('openSharePanel', () => {
  543. it('should return the correct type', () => {
  544. const expectedResult = {
  545. type: ActionTypes.OPEN_SHARE_PANEL,
  546. payload: {
  547. id: mockDisplayId,
  548. title: mockDisplayTitle
  549. }
  550. }
  551. expect(actions.openSharePanel(mockDisplayId, mockDisplayTitle)).toEqual(
  552. expectedResult
  553. )
  554. })
  555. })
  556. describe('closeSharePanel', () => {
  557. it('should return the correct type', () => {
  558. const expectedResult = {
  559. type: ActionTypes.CLOSE_SHARE_PANEL
  560. }
  561. expect(actions.closeSharePanel()).toEqual(expectedResult)
  562. })
  563. })
  564. describe('resetDisplayState', () => {
  565. it('should return the correct type', () => {
  566. const expectedResult = {
  567. type: ActionTypes.RESET_DISPLAY_STATE,
  568. payload: {}
  569. }
  570. expect(actions.resetDisplayState()).toEqual(expectedResult)
  571. })
  572. })
  573. describe('monitoredSyncDataAction', () => {
  574. it('should return the correct type', () => {
  575. const expectedResult = {
  576. type: ActionTypes.MONITORED_SYNC_DATA_ACTION,
  577. payload: {}
  578. }
  579. expect(actions.monitoredSyncDataAction()).toEqual(expectedResult)
  580. })
  581. })
  582. describe('monitoredSearchDataAction', () => {
  583. it('should return the correct type', () => {
  584. const expectedResult = {
  585. type: ActionTypes.MONITORED_SEARCH_DATA_ACTION,
  586. payload: {}
  587. }
  588. expect(actions.monitoredSearchDataAction()).toEqual(expectedResult)
  589. })
  590. })
  591. describe('monitoredLinkageDataAction', () => {
  592. it('should return the correct type', () => {
  593. const expectedResult = {
  594. type: ActionTypes.MONITORED_LINKAGE_DATA_ACTION,
  595. payload: {}
  596. }
  597. expect(actions.monitoredLinkageDataAction()).toEqual(expectedResult)
  598. })
  599. })
  600. })