forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set thumbnail through the set_thumbnail endpoint and add Apply button (…
- Loading branch information
1 parent
a31e9d2
commit 3cda34b
Showing
13 changed files
with
260 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
geonode_mapstore_client/client/js/epics/__tests__/gnresource-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import axios from '@mapstore/framework/libs/ajax'; | ||
import { testEpic } from '@mapstore/framework/epics/__tests__/epicTestUtils'; | ||
import { gnViewerSetNewResourceThumbnail } from '@js/epics/gnresource'; | ||
import { setResourceThumbnail, UPDATE_RESOURCE_PROPERTIES } from '@js/actions/gnresource'; | ||
import { | ||
SHOW_NOTIFICATION | ||
} from '@mapstore/framework/actions/notifications'; | ||
|
||
let mockAxios; | ||
|
||
describe('gnsave epics', () => { | ||
beforeEach(done => { | ||
global.__DEVTOOLS__ = true; | ||
mockAxios = new MockAdapter(axios); | ||
setTimeout(done); | ||
}); | ||
afterEach(done => { | ||
delete global.__DEVTOOLS__; | ||
mockAxios.restore(); | ||
setTimeout(done); | ||
}); | ||
|
||
it('should apply new resource thumbnail', (done) => { | ||
const NUM_ACTIONS = 2; | ||
const pk = 1; | ||
const testState = { | ||
gnresource: { | ||
id: pk, | ||
data: { | ||
'title': 'Map', | ||
'thumbnail_url': 'thumbnail.jpeg' | ||
} | ||
} | ||
}; | ||
mockAxios.onPut(new RegExp(`resources/${pk}/set_thumbnail`)) | ||
.reply(() => [200, { thumbnail_url: 'test_url' }]); | ||
|
||
testEpic( | ||
gnViewerSetNewResourceThumbnail, | ||
NUM_ACTIONS, | ||
setResourceThumbnail(), | ||
(actions) => { | ||
try { | ||
expect(actions.map(({ type }) => type)) | ||
.toEqual([ | ||
UPDATE_RESOURCE_PROPERTIES, | ||
SHOW_NOTIFICATION | ||
]); | ||
} catch (e) { | ||
done(e); | ||
} | ||
done(); | ||
}, | ||
testState | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.