123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- /*
- * <<
- * Davinci
- * ==
- * Copyright (C) 2016 - 2017 EDP
- * ==
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * >>
- */
- import { ActionTypes } from 'app/containers/Display/constants'
- import actions from 'app/containers/Display/actions'
- import {
- mockDisplayId,
- mockSlideId,
- mockGraphLayerFormed,
- mockWidgetFormed,
- mockFormedViews,
- mockHttpError,
- mockCover,
- mockSlide,
- mockSlideCoverUploadImgSrc,
- mockSlideSize,
- mockLayerScale,
- mockGraphLayerId,
- mockDeltaSize,
- mockFinish,
- mockDeltaPosition,
- mockEventTrigger,
- mockOperation,
- mockAlignmentType,
- mockSelected,
- mockExclusive,
- mockChangedOperationInfo,
- mockBaseLines,
- mockLayerParamsUnChanged,
- mockChangedParams,
- mockShareLinkParams,
- mockShareToken,
- mockAuthShareToken,
- mockPasswordToken,
- mockPassword,
- mockDisplayTitle
- } from './fixtures'
- describe('Display Actions', () => {
- describe('loadSlideDetail', () => {
- it('should return the correct type and passed displayId', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_SLIDE_DETAIL,
- payload: {
- displayId: mockDisplayId,
- slideId: mockSlideId
- }
- }
- expect(actions.loadSlideDetail(mockDisplayId, mockSlideId)).toEqual(
- expectedResult
- )
- })
- })
- describe('slideDetailLoaded', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_SLIDE_DETAIL_SUCCESS,
- payload: {
- slideId: mockSlideId,
- layers: [mockGraphLayerFormed],
- widgets: [mockWidgetFormed],
- formedViews: mockFormedViews
- }
- }
- expect(
- actions.slideDetailLoaded(
- mockSlideId,
- [mockGraphLayerFormed],
- [mockWidgetFormed],
- mockFormedViews
- )
- ).toEqual(expectedResult)
- })
- })
- describe('loadSlideDetailFail', () => {
- it('should return the correct type and error', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_SLIDE_DETAIL_FAILURE,
- payload: {
- err: mockHttpError
- }
- }
- expect(actions.loadSlideDetailFail(mockHttpError)).toEqual(expectedResult)
- })
- })
- describe('uploadCurrentSlideCover', () => {
- it('should return the correct type and right cover, slide', () => {
- const expectedResult = {
- type: ActionTypes.UPLOAD_CURRENT_SLIDE_COVER,
- payload: {
- cover: mockCover,
- slide: mockSlide
- }
- }
- expect(actions.uploadCurrentSlideCover(mockCover, mockSlide)).toEqual(
- expectedResult
- )
- })
- })
- describe('currentSlideCoverUploaded', () => {
- it('should return the correct type and passed result', () => {
- const expectedResult = {
- type: ActionTypes.UPLOAD_CURRENT_SLIDE_COVER_SUCCESS,
- payload: {
- result: mockSlideCoverUploadImgSrc
- }
- }
- expect(
- actions.currentSlideCoverUploaded(mockSlideCoverUploadImgSrc)
- ).toEqual(expectedResult)
- })
- })
- describe('uploadCurrentSlideCoverFail', () => {
- it('should return the correct type and throw err', () => {
- const expectedResult = {
- type: ActionTypes.UPLOAD_CURRENT_SLIDE_COVER_FAILURE,
- payload: {
- error: mockHttpError
- }
- }
- expect(actions.uploadCurrentSlideCoverFail(mockHttpError)).toEqual(
- expectedResult
- )
- })
- })
- describe('resizeLayer', () => {
- it('should return the correct type and resize params', () => {
- const expectedResult = {
- type: ActionTypes.RESIZE_LAYER,
- payload: {
- slideSize: mockSlideSize,
- scale: mockLayerScale,
- layerId: mockGraphLayerId,
- deltaSize: mockDeltaSize,
- finish: mockFinish
- }
- }
- expect(
- actions.resizeLayer(
- mockSlideSize,
- mockLayerScale,
- mockGraphLayerId,
- mockDeltaSize,
- mockFinish
- )
- ).toEqual(expectedResult)
- })
- })
- describe('resizeLayerAdjusted', () => {
- it('should return the correct type and passed deltaSize', () => {
- const expectedResult = {
- type: ActionTypes.RESIZE_LAYER_ADJUSTED,
- payload: {
- layerIds: [mockGraphLayerId],
- deltaSize: mockDeltaSize,
- finish: mockFinish
- }
- }
- expect(
- actions.resizeLayerAdjusted([mockGraphLayerId], mockDeltaSize, mockFinish)
- ).toEqual(expectedResult)
- })
- })
- describe('dragLayer', () => {
- it('should return the correct type and drag params', () => {
- const expectedResult = {
- type: ActionTypes.DRAG_LAYER,
- payload: {
- slideSize: mockSlideSize,
- scale: mockLayerScale,
- layerId: mockGraphLayerId,
- deltaPosition: mockDeltaPosition,
- eventTrigger: mockEventTrigger,
- finish: mockFinish
- }
- }
- expect(
- actions.dragLayer(
- mockSlideSize,
- mockLayerScale,
- mockDeltaPosition,
- mockEventTrigger,
- mockFinish,
- mockGraphLayerId
- )
- ).toEqual(expectedResult)
- })
- })
- describe('dragLayerAdjusted', () => {
- it('should return the correct type and drag params', () => {
- const expectedResult = {
- type: ActionTypes.DRAG_LAYER_ADJUSTED,
- payload: {
- layerIds: [mockGraphLayerId],
- slideSize: mockSlideSize,
- deltaPosition: mockDeltaPosition,
- finish: mockFinish
- }
- }
- expect(
- actions.dragLayerAdjusted(
- [mockGraphLayerId],
- mockSlideSize,
- mockDeltaPosition,
- mockFinish
- )
- ).toEqual(expectedResult)
- })
- })
- describe('changeLayersStack', () => {
- it('should return the correct type and passed operation', () => {
- const expectedResult = {
- type: ActionTypes.CHANGE_LAYERS_STACK,
- payload: {
- operation: mockOperation
- }
- }
- expect(actions.changeLayersStack(mockOperation)).toEqual(expectedResult)
- })
- })
- describe('setLayersAlignment', () => {
- it('should return the correct type and passed alignmentType', () => {
- const expectedResult = {
- type: ActionTypes.SET_LAYERS_ALIGNMENT,
- payload: {
- alignmentType: mockAlignmentType
- }
- }
- expect(actions.setLayersAlignment(mockAlignmentType)).toEqual(
- expectedResult
- )
- })
- })
- describe('selectLayer', () => {
- it('should return the correct type and passed layer status', () => {
- const expectedResult = {
- type: ActionTypes.SELECT_LAYER,
- payload: {
- layerId: mockGraphLayerId,
- selected: mockSelected,
- exclusive: mockExclusive
- }
- }
- expect(
- actions.selectLayer(mockGraphLayerId, mockSelected, mockExclusive)
- ).toEqual(expectedResult)
- })
- })
- describe('clearLayersOperationInfo', () => {
- it('should return the correct type and passed changedInfo', () => {
- const expectedResult = {
- type: ActionTypes.CLEAR_LAYERS_OPERATION_INFO,
- payload: {
- changedInfo: mockChangedOperationInfo
- }
- }
- expect(actions.clearLayersOperationInfo(mockChangedOperationInfo)).toEqual(
- expectedResult
- )
- })
- })
- describe('clearEditorBaselines', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.CLEAR_EDITOR_BASELINES,
- payload: {}
- }
- expect(actions.clearEditorBaselines()).toEqual(expectedResult)
- })
- })
- describe('showEditorBaselines', () => {
- it('should return the correct type and baselines', () => {
- const expectedResult = {
- type: ActionTypes.SHOW_EDITOR_BASELINES,
- payload: {
- baselines: [mockBaseLines]
- }
- }
- expect(actions.showEditorBaselines([mockBaseLines])).toEqual(expectedResult)
- })
- })
- describe('copySlideLayers', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.COPY_SLIDE_LAYERS,
- payload: {}
- }
- expect(actions.copySlideLayers()).toEqual(expectedResult)
- })
- })
- describe('slideLayersCopied', () => {
- it('should return the correct type and layer', () => {
- const expectedResult = {
- type: ActionTypes.COPY_SLIDE_LAYERS_SUCCESS,
- payload: {
- layers: [mockGraphLayerFormed]
- }
- }
- expect(actions.slideLayersCopied([mockGraphLayerFormed])).toEqual(expectedResult)
- })
- })
- describe('pasteSlideLayers', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.PASTE_SLIDE_LAYERS,
- payload: {}
- }
- expect(actions.pasteSlideLayers()).toEqual(expectedResult)
- })
- })
- describe('addSlideLayers', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.ADD_SLIDE_LAYERS,
- payload: {
- displayId: mockDisplayId,
- slideId: mockSlideId,
- layers: [mockGraphLayerFormed],
- widgets: [mockWidgetFormed]
- }
- }
- expect(
- actions.addSlideLayers(
- mockDisplayId,
- mockSlideId,
- [mockGraphLayerFormed],
- [mockWidgetFormed]
- )
- ).toEqual(expectedResult)
- })
- })
- describe('slideLayersAdded', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.ADD_SLIDE_LAYERS_SUCCESS,
- payload: {
- slideId: mockSlideId,
- layers: [mockGraphLayerFormed],
- widgets: [mockWidgetFormed]
- }
- }
- expect(
- actions.slideLayersAdded(mockSlideId, [mockGraphLayerFormed], [mockWidgetFormed])
- ).toEqual(expectedResult)
- })
- })
- describe('addSlideLayersFail', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.ADD_SLIDE_LAYERS_FAILURE,
- payload: {}
- }
- expect(actions.addSlideLayersFail()).toEqual(expectedResult)
- })
- })
- describe('editSlideLayers', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.EDIT_SLIDE_LAYERS,
- payload: {
- displayId: mockDisplayId,
- slideId: mockSlideId,
- layers: [mockGraphLayerFormed],
- layerParamsUnChanged: mockLayerParamsUnChanged
- }
- }
- expect(
- actions.editSlideLayers(
- mockDisplayId,
- mockSlideId,
- [mockGraphLayerFormed],
- mockLayerParamsUnChanged
- )
- ).toEqual(expectedResult)
- })
- })
- describe('slideLayersEdited', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.EDIT_SLIDE_LAYERS_SUCCESS,
- payload: {
- slideId: mockSlideId,
- layers: [mockGraphLayerFormed]
- }
- }
- expect(actions.slideLayersEdited(mockSlideId, [mockGraphLayerFormed])).toEqual(
- expectedResult
- )
- })
- })
- describe('editSlideLayersFail', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.EDIT_SLIDE_LAYERS_FAILURE,
- payload: {}
- }
- expect(actions.editSlideLayersFail()).toEqual(expectedResult)
- })
- })
- describe('editSlideLayerParams', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.EDIT_SLIDE_LAYER_PARAMS,
- payload: {
- layerId: mockGraphLayerId,
- changedParams: mockChangedParams
- }
- }
- expect(
- actions.editSlideLayerParams(mockGraphLayerId, mockChangedParams)
- ).toEqual(expectedResult)
- })
- })
- describe('deleteSlideLayers', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.DELETE_SLIDE_LAYERS,
- payload: {
- displayId: mockDisplayId,
- slideId: mockSlideId
- }
- }
- expect(actions.deleteSlideLayers(mockDisplayId, mockSlideId)).toEqual(
- expectedResult
- )
- })
- })
- describe('changeLayerOperationInfo', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.CHANGE_LAYER_OPERATION_INFO,
- payload: {
- layerId: mockGraphLayerId,
- changedInfo: mockChangedOperationInfo
- }
- }
- expect(
- actions.changeLayerOperationInfo(mockGraphLayerId, mockChangedOperationInfo)
- ).toEqual(expectedResult)
- })
- })
- describe('slideLayersDeleted', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.DELETE_SLIDE_LAYERS_SUCCESS,
- payload: {
- slideId: mockSlideId,
- layerIds: [mockGraphLayerId]
- }
- }
- expect(actions.slideLayersDeleted(mockSlideId, [mockGraphLayerId])).toEqual(
- expectedResult
- )
- })
- })
- describe('deleteSlideLayersFail', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.DELETE_SLIDE_LAYERS_FAILURE,
- payload: {}
- }
- expect(actions.deleteSlideLayersFail()).toEqual(expectedResult)
- })
- })
- describe('loadDisplayShareLink', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_DISPLAY_SHARE_LINK,
- payload: {
- params: mockShareLinkParams
- }
- }
- expect(actions.loadDisplayShareLink(mockShareLinkParams)).toEqual(
- expectedResult
- )
- })
- })
- describe('displayShareLinkLoaded', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_DISPLAY_SHARE_LINK_SUCCESS,
- payload: {
- shareToken: mockShareToken
- }
- }
- expect(actions.displayShareLinkLoaded(mockShareToken)).toEqual(
- expectedResult
- )
- })
- })
- describe('displayAuthorizedShareLinkLoaded', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_DISPLAY_AUTHORIZED_SHARE_LINK_SUCCESS,
- payload: {
- authorizedShareToken: mockAuthShareToken
- }
- }
- expect(
- actions.displayAuthorizedShareLinkLoaded(mockAuthShareToken)
- ).toEqual(expectedResult)
- })
- })
- describe('displayPasswordShareLinkLoaded', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_DISPLAY_PASSWORD_SHARE_LINK_SUCCESS,
- payload: {
- passwordShareToken: mockPasswordToken,
- password: mockPassword
- }
- }
- expect(
- actions.displayPasswordShareLinkLoaded(mockPasswordToken, mockPassword)
- ).toEqual(expectedResult)
- })
- })
- describe('loadDisplayShareLinkFail', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.LOAD_DISPLAY_SHARE_LINK_FAILURE,
- payload: {}
- }
- expect(actions.loadDisplayShareLinkFail()).toEqual(expectedResult)
- })
- })
- describe('openSharePanel', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.OPEN_SHARE_PANEL,
- payload: {
- id: mockDisplayId,
- title: mockDisplayTitle
- }
- }
- expect(actions.openSharePanel(mockDisplayId, mockDisplayTitle)).toEqual(
- expectedResult
- )
- })
- })
- describe('closeSharePanel', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.CLOSE_SHARE_PANEL
- }
- expect(actions.closeSharePanel()).toEqual(expectedResult)
- })
- })
- describe('resetDisplayState', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.RESET_DISPLAY_STATE,
- payload: {}
- }
- expect(actions.resetDisplayState()).toEqual(expectedResult)
- })
- })
- describe('monitoredSyncDataAction', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.MONITORED_SYNC_DATA_ACTION,
- payload: {}
- }
- expect(actions.monitoredSyncDataAction()).toEqual(expectedResult)
- })
- })
- describe('monitoredSearchDataAction', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.MONITORED_SEARCH_DATA_ACTION,
- payload: {}
- }
- expect(actions.monitoredSearchDataAction()).toEqual(expectedResult)
- })
- })
- describe('monitoredLinkageDataAction', () => {
- it('should return the correct type', () => {
- const expectedResult = {
- type: ActionTypes.MONITORED_LINKAGE_DATA_ACTION,
- payload: {}
- }
- expect(actions.monitoredLinkageDataAction()).toEqual(expectedResult)
- })
- })
- })
|