Skip to content

Commit

Permalink
geosolutions-it#10648: handle unit test for 'savePendingFeatureGridCh…
Browse files Browse the repository at this point in the history
…anges'
  • Loading branch information
mahmoudadel54 committed Nov 5, 2024
1 parent e76bec3 commit 2c91bcd
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions web/client/epics/__tests__/featuregrid-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ import {
setLayer,
setViewportFilter, SET_VIEWPORT_FILTER,
SAVING,
saveChanges
saveChanges,
SAVE_SUCCESS
} from '../../actions/featuregrid';

import { SET_HIGHLIGHT_FEATURES_PATH } from '../../actions/highlight';
Expand Down Expand Up @@ -150,6 +151,9 @@ import { onLocationChanged } from 'connected-react-router';
import { TEST_TIMEOUT, testEpic, addTimeoutEpic } from './epicTestUtils';
import { getDefaultFeatureProjection } from '../../utils/FeatureGridUtils';
import { isEmpty, isNil } from 'lodash';
import axios from "../../libs/ajax";
import MockAdapter from "axios-mock-adapter";

const filterObj = {
featureTypeName: 'TEST',
groupFields: [
Expand Down Expand Up @@ -1825,6 +1829,13 @@ describe('featuregrid Epics', () => {
}));
});
describe('updateSelectedOnSaveOrCloseFeatureGrid', () => {
let mockAxios;
beforeEach(() => {
mockAxios = new MockAdapter(axios);
});
afterEach(() => {
mockAxios.restore();
});
it("test savePendingFeatureGridChanges", (done) => {
const stateFeaturegrid = {
query: {
Expand Down Expand Up @@ -1894,12 +1905,15 @@ describe('featuregrid Epics', () => {
]
}
};
const payloadSample = `<wfs:Transaction service="WFS" version="1.1.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs" xmlns:mapstore="http://localhost:8080/geoserver/mapstore"><wfs:Update typeName="mapstore:TEST_LAYER"><wfs:Property><wfs:Name>Integer</wfs:Name><wfs:Value>50</wfs:Value></wfs:Property>,<wfs:Property><wfs:Name>Long</wfs:Name><wfs:Value>55</wfs:Value></wfs:Property><ogc:Filter><ogc:FeatureId fid="TEST_LAYER.13"/></ogc:Filter></wfs:Update></wfs:Transaction>`;
mockAxios.onPost(stateFeaturegrid.query.searchUrl, payloadSample).replyOnce(200);
testEpic(
savePendingFeatureGridChanges,
1,
2,
saveChanges(),
([a]) => {
([a, b]) => {
expect(a.type).toEqual(SAVING);
expect(b.type).toEqual(SAVE_SUCCESS);
done();
}, stateFeaturegrid
);
Expand Down

0 comments on commit 2c91bcd

Please sign in to comment.