How to use retval method in wpt

Best JavaScript code snippet using wpt

featuregrid-test.js

Source:featuregrid-test.js Github

copy

Full Screen

1/**2 * Copyright 2016, GeoSolutions Sas.3 * All rights reserved.4 *5 * This source code is licensed under the BSD-style license found in the6 * LICENSE file in the root directory of this source tree.7 */8import expect from 'expect';9import { isEmpty, isEqual } from 'lodash';10import {11 launchUpdateFilterFunc,12 LAUNCH_UPDATE_FILTER_FUNC,13 SELECT_FEATURES,14 selectFeatures,15 changePage,16 CHANGE_PAGE,17 sort,18 SORT_BY,19 setSelectionOptions,20 SET_SELECTION_OPTIONS,21 MODES,22 TOGGLE_MODE,23 toggleEditMode,24 toggleViewMode,25 featureModified,26 FEATURES_MODIFIED,27 createNewFeatures,28 CREATE_NEW_FEATURE,29 saveChanges,30 SAVE_CHANGES,31 saveSuccess,32 SAVE_SUCCESS,33 deleteFeatures,34 DELETE_SELECTED_FEATURES,35 startEditingFeature,36 START_EDITING_FEATURE,37 featureSaving,38 SAVING,39 saveError,40 SAVE_ERROR,41 clearChanges,42 CLEAR_CHANGES,43 geometryChanged,44 GEOMETRY_CHANGED,45 startDrawingFeature,46 START_DRAWING_FEATURE,47 deleteGeometry,48 DELETE_GEOMETRY,49 deleteGeometryFeature,50 DELETE_GEOMETRY_FEATURE,51 clearChangeConfirmed,52 CLEAR_CHANGES_CONFIRMED,53 deleteFeaturesConfirm,54 DELETE_SELECTED_FEATURES_CONFIRM,55 openFeatureGrid,56 OPEN_FEATURE_GRID,57 closeFeatureGrid,58 CLOSE_FEATURE_GRID,59 closeFeatureGridConfirm,60 CLOSE_FEATURE_GRID_CONFIRM,61 closeFeatureGridConfirmed,62 FEATURE_GRID_CLOSE_CONFIRMED,63 updateFilter,64 UPDATE_FILTER,65 zoomAll,66 ZOOM_ALL,67 openAdvancedSearch,68 OPEN_ADVANCED_SEARCH,69 initPlugin,70 INIT_PLUGIN,71 sizeChange,72 SIZE_CHANGE,73 START_SYNC_WMS,74 startSyncWMS,75 storeAdvancedSearchFilter,76 STORE_ADVANCED_SEARCH_FILTER,77 setUp,78 SET_UP,79 setTimeSync,80 SET_TIME_SYNC,81 featureGridQueryResult,82 GRID_QUERY_RESULT,83 moreFeatures,84 LOAD_MORE_FEATURES,85 hideSyncPopover,86 HIDE_SYNC_POPOVER,87 toggleShowAgain,88 TOGGLE_SHOW_AGAIN_FLAG89} from '../featuregrid';90const idFeature = "2135";91const feature = {92 type: "Feature",93 id: idFeature,94 properties: {95 name: "f.name"96 },97 geometry: {98 type: "Point",99 coordinates: [1, 2]100 }101};102const features = [feature, feature];103const options = {editEnabled: true};104describe('Test correctness of featurgrid actions', () => {105 it('Test deleteGeometryFeature action creator', () => {106 const retval = deleteGeometryFeature(features);107 expect(retval).toExist();108 expect(retval.features).toExist();109 expect(retval.features.length).toBe(features.length);110 expect(retval.type).toBe(DELETE_GEOMETRY_FEATURE);111 });112 it('Test deleteGeometryFeature action creator', () => {113 const retval = launchUpdateFilterFunc({});114 expect(retval).toBeTruthy();115 expect(retval.updateFilterAction).toBeTruthy();116 expect(retval.type).toBe(LAUNCH_UPDATE_FILTER_FUNC);117 });118 it('Test deleteGeometry action creator', () => {119 const retval = deleteGeometry();120 expect(retval).toExist();121 expect(retval.type).toBe(DELETE_GEOMETRY);122 });123 it('Test initPlugin action creator', () => {124 const someOption = "someValue";125 const retval = initPlugin({someOption});126 expect(retval).toExist();127 expect(retval.type).toBe(INIT_PLUGIN);128 expect(retval.options.someOption).toBe(someOption);129 // test with empty value, returns empty options130 const retval2 = initPlugin();131 expect(retval2).toExist();132 expect(retval2.type).toBe(INIT_PLUGIN);133 expect(isEmpty(retval2.options)).toBe(true);134 expect(isEqual(retval2.options, {})).toBe(true);135 });136 it('Test closeFeatureGridConfirmed action creator', () => {137 const retval = closeFeatureGridConfirmed();138 expect(retval).toExist();139 expect(retval.type).toBe(FEATURE_GRID_CLOSE_CONFIRMED);140 });141 it('Test clearChangeConfirmed action creator', () => {142 const retval = clearChangeConfirmed();143 expect(retval).toExist();144 expect(retval.type).toBe(CLEAR_CHANGES_CONFIRMED);145 });146 it('Test hideSyncPopover action creator', () => {147 const retval = hideSyncPopover();148 expect(retval).toExist();149 expect(retval.type).toBe(HIDE_SYNC_POPOVER);150 });151 it('Test toggleShowAgain action creator', () => {152 const retval = toggleShowAgain();153 expect(retval).toExist();154 expect(retval.type).toBe(TOGGLE_SHOW_AGAIN_FLAG);155 });156 it('Test startDrawingFeature action creator', () => {157 const retval = startDrawingFeature();158 expect(retval).toExist();159 expect(retval.type).toBe(START_DRAWING_FEATURE);160 });161 it('Test geometryChanged action creator', () => {162 const retval = geometryChanged([feature]);163 expect(retval).toExist();164 expect(retval.type).toBe(GEOMETRY_CHANGED);165 expect(retval.features).toExist();166 expect(retval.features[0].id).toBe(idFeature);167 expect(retval.features.length).toBe(1);168 });169 it('Test selectFeature action creator', () => {170 const someFeatures = [1, 2];171 const retval = selectFeatures(someFeatures);172 expect(retval).toExist();173 expect(retval.type).toBe(SELECT_FEATURES);174 expect(retval.features).toExist();175 expect(retval.features).toBe(someFeatures);176 });177 it('Test changePage action creator', () => {178 const retval = changePage(1, 2);179 expect(retval).toExist();180 expect(retval.type).toBe(CHANGE_PAGE);181 expect(retval.page).toBe(1);182 expect(retval.size).toBe(2);183 });184 it('Test sort action creator', () => {185 const retval = sort("attr", "ASC");186 expect(retval).toExist();187 expect(retval.type).toBe(SORT_BY);188 expect(retval.sortBy).toBe("attr");189 expect(retval.sortOrder).toBe("ASC");190 });191 it('Test startEditingFeature', () => {192 const retval = startEditingFeature(feature, options);193 expect(retval).toExist();194 expect(retval.type).toBe(START_EDITING_FEATURE);195 });196 it('Test setSelectionOptions', () => {197 const retval = setSelectionOptions({multiselect: true});198 expect(retval).toExist();199 expect(retval.type).toBe(SET_SELECTION_OPTIONS);200 expect(retval.multiselect).toExist();201 expect(retval.multiselect).toBeTruthy();202 });203 it('Test toggleEditMode AND toggleViewMode', () => {204 let retval = toggleEditMode();205 expect(retval).toExist();206 expect(retval.type).toBe(TOGGLE_MODE);207 expect(retval.mode).toExist();208 expect(retval.mode).toBe(MODES.EDIT);209 retval = toggleViewMode();210 expect(retval).toExist();211 expect(retval.type).toBe(TOGGLE_MODE);212 expect(retval.mode).toExist();213 expect(retval.mode).toBe(MODES.VIEW);214 });215 it('Test featureModified', () => {216 const retval = featureModified([feature, feature], true);217 expect(retval).toExist();218 expect(retval.type).toBe(FEATURES_MODIFIED);219 expect(retval.features).toExist();220 expect(retval.features.length).toBe(2);221 expect(retval.updated).toBeTruthy();222 });223 it('Test createNewFeatures', () => {224 const retval = createNewFeatures(features);225 expect(retval).toExist();226 expect(retval.type).toBe(CREATE_NEW_FEATURE);227 expect(retval.features).toExist();228 expect(retval.features.length).toBe(2);229 });230 it('Test saveChanges', () => {231 const retval = saveChanges();232 expect(retval).toExist();233 expect(retval.type).toBe(SAVE_CHANGES);234 });235 it('Test saveSuccess', () => {236 const retval = saveSuccess();237 expect(retval).toExist();238 expect(retval.type).toBe(SAVE_SUCCESS);239 });240 it('Test deleteFeatures', () => {241 const retval = deleteFeatures();242 expect(retval).toExist();243 expect(retval.type).toBe(DELETE_SELECTED_FEATURES);244 });245 it('Test featureSaving', () => {246 const retval = featureSaving();247 expect(retval).toExist();248 expect(retval.type).toBe(SAVING);249 });250 it('Test clearChanges', () => {251 const retval = clearChanges();252 expect(retval).toExist();253 expect(retval.type).toBe(CLEAR_CHANGES);254 });255 it('Test deleteFeaturesConfirm', () => {256 const retval = deleteFeaturesConfirm();257 expect(retval).toExist();258 expect(retval.type).toBe(DELETE_SELECTED_FEATURES_CONFIRM);259 });260 it('Test openFeatureGrid', () => {261 const retval = openFeatureGrid();262 expect(retval).toExist();263 expect(retval.type).toBe(OPEN_FEATURE_GRID);264 });265 it('Test closeFeatureGrid', () => {266 const retval = closeFeatureGrid();267 expect(retval).toExist();268 expect(retval.type).toBe(CLOSE_FEATURE_GRID);269 });270 it('Test closeFeatureGridConfirm', () => {271 const retval = closeFeatureGridConfirm();272 expect(retval).toExist();273 expect(retval.type).toBe(CLOSE_FEATURE_GRID_CONFIRM);274 });275 it('Test saveError', () => {276 const retval = saveError();277 expect(retval).toExist();278 expect(retval.type).toBe(SAVE_ERROR);279 });280 it('Test zoomAll', () => {281 const retval = zoomAll();282 expect(retval).toExist();283 expect(retval.type).toBe(ZOOM_ALL);284 });285 it('Test startSyncWMS', () => {286 const retval = startSyncWMS();287 expect(retval).toExist();288 expect(retval.type).toBe(START_SYNC_WMS);289 });290 it('Test openAdvancedSearch', () => {291 const retval = openAdvancedSearch();292 expect(retval).toExist();293 expect(retval.type).toBe(OPEN_ADVANCED_SEARCH);294 });295 it('Test updateFilter', () => {296 const update = {name: "A"};297 const retval = updateFilter(update);298 expect(retval).toExist();299 expect(retval.type).toBe(UPDATE_FILTER);300 expect(retval.update).toBe(update);301 });302 it('Test sizeChange', () => {303 const size = 0.5;304 const dockProps = {maxDockSize: 0.7, minDockSize: 0.1};305 const retval = sizeChange(size, dockProps);306 expect(retval).toExist();307 expect(retval.type).toBe(SIZE_CHANGE);308 expect(retval.size).toBe(size);309 expect(retval.dockProps).toEqual(dockProps);310 });311 it('Test storeAdvancedSearchFilter', () => {312 const filterObj = {name: "A"};313 const retval = storeAdvancedSearchFilter(filterObj);314 expect(retval).toExist();315 expect(retval.type).toBe(STORE_ADVANCED_SEARCH_FILTER);316 expect(retval.filterObj).toBe(filterObj);317 });318 it('Test storeAdvancedSearchFilter', () => {319 const filterObj = {name: "A"};320 const retval = storeAdvancedSearchFilter(filterObj);321 expect(retval).toExist();322 expect(retval.type).toBe(STORE_ADVANCED_SEARCH_FILTER);323 expect(retval.filterObj).toBe(filterObj);324 });325 it('Test featureGridQueryResult', () => {326 const pages = [];327 const retval = featureGridQueryResult(features, pages);328 expect(retval).toExist();329 expect(retval.type).toBe(GRID_QUERY_RESULT);330 expect(retval.features).toBe(features);331 expect(retval.pages).toBe(pages);332 });333 it('Test moreFeatures', () => {334 const pages = {startPage: 0, endPage: 2};335 const retval = moreFeatures(pages);336 expect(retval).toExist();337 expect(retval.type).toBe(LOAD_MORE_FEATURES);338 expect(retval.pages).toBe(pages);339 });340 it('Test setUp', () => {341 const showFilteredObject = true;342 expect(setUp({ showFilteredObject })).toEqual({ type: SET_UP, options: { showFilteredObject }});343 expect(setUp({ showFilteredObject, timeSync: true })).toEqual({ type: SET_UP, options: { showFilteredObject, timeSync: true } });344 });345 it('setTimeSync', () => {346 expect(setTimeSync(true)).toEqual({ type: SET_TIME_SYNC, value: true });347 expect(setTimeSync(false)).toEqual({ type: SET_TIME_SYNC, value: false });348 });...

Full Screen

Full Screen

queryform-test.js

Source:queryform-test.js Github

copy

Full Screen

1/**2 * Copyright 2015, GeoSolutions Sas.3 * All rights reserved.4 *5 * This source code is licensed under the BSD-style license found in the6 * LICENSE file in the root directory of this source tree.7 */8import expect from 'expect';9import {10 ADD_FILTER_FIELD,11 ADD_GROUP_FIELD,12 REMOVE_FILTER_FIELD,13 UPDATE_FILTER_FIELD,14 UPDATE_EXCEPTION_FIELD,15 UPDATE_LOGIC_COMBO,16 REMOVE_GROUP_FIELD,17 CHANGE_CASCADING_VALUE,18 EXPAND_ATTRIBUTE_PANEL,19 EXPAND_SPATIAL_PANEL,20 SELECT_SPATIAL_METHOD,21 UPDATE_GEOMETRY,22 SELECT_SPATIAL_OPERATION,23 REMOVE_SPATIAL_SELECT,24 SHOW_SPATIAL_DETAILS,25 ZONE_SEARCH,26 ZONE_SEARCH_ERROR,27 ZONE_FILTER,28 ZONE_CHANGE,29 ZONES_RESET,30 SHOW_GENERATED_FILTER,31 QUERY_FORM_RESET,32 CHANGE_DWITHIN_VALUE,33 QUERY_FORM_SEARCH,34 LOAD_FILTER,35 SIMPLE_FILTER_FIELD_UPDATE,36 ADD_SIMPLE_FILTER_FIELD,37 REMOVE_SIMPLE_FILTER_FIELD,38 REMOVE_ALL_SIMPLE_FILTER_FIELDS,39 SELECT_VIEWPORT_SPATIAL_METHOD,40 CHANGE_SPATIAL_ATTRIBUTE,41 TOGGLE_AUTOCOMPLETE_MENU,42 SET_AUTOCOMPLETE_MODE,43 CHANGE_SPATIAL_FILTER_VALUE,44 setAutocompleteMode,45 toggleMenu,46 changeDwithinValue,47 resetZones,48 zoneChange,49 zoneSearch,50 zoneSearchError,51 zoneFilter,52 zoneGetValues,53 query,54 search,55 loadFilter,56 reset,57 addFilterField,58 addGroupField,59 removeFilterField,60 updateFilterField,61 updateExceptionField,62 updateLogicCombo,63 removeGroupField,64 changeCascadingValue,65 expandAttributeFilterPanel,66 expandSpatialFilterPanel,67 selectSpatialMethod,68 updateGeometrySpatialField,69 selectViewportSpatialMethod,70 selectSpatialOperation,71 removeSpatialSelection,72 changeSpatialAttribute,73 showSpatialSelectionDetails,74 simpleFilterFieldUpdate,75 addSimpleFilterField,76 removeSimpleFilterField,77 removeAllSimpleFilterFields,78 changeSpatialFilterValue79} from '../queryform';80describe('Test correctness of the queryform actions', () => {81 it('addFilterField', () => {82 let groupId = 1;83 var retval = addFilterField(groupId);84 expect(retval).toExist();85 expect(retval.type).toBe(ADD_FILTER_FIELD);86 expect(retval.groupId).toBe(1);87 });88 it('toggleMenu', () => {89 let status = true;90 let rowId = 100;91 var retval = toggleMenu(rowId, status);92 expect(retval).toExist();93 expect(retval.type).toBe(TOGGLE_AUTOCOMPLETE_MENU);94 expect(retval.rowId).toBe(rowId);95 expect(retval.status).toBe(status);96 });97 it('set autocomplete', () => {98 let status = true;99 var retval = setAutocompleteMode(status);100 expect(retval).toExist();101 expect(retval.type).toBe(SET_AUTOCOMPLETE_MODE);102 expect(retval.status).toBe(status);103 });104 it('addGroupField', () => {105 let groupId = 1;106 let index = 0;107 var retval = addGroupField(groupId, index);108 expect(retval).toExist();109 expect(retval.type).toBe(ADD_GROUP_FIELD);110 expect(retval.groupId).toBe(1);111 expect(retval.index).toBe(0);112 });113 it('updateGeometrySpatialField', () => {114 const geometry = {center: [0, 1], coordinates: []};115 const retval = updateGeometrySpatialField(geometry);116 expect(retval).toExist();117 expect(retval.type).toBe(UPDATE_GEOMETRY);118 expect(retval.geometry).toBe(geometry);119 });120 it('selectViewportSpatialMethod', () => {121 const retval = selectViewportSpatialMethod();122 expect(retval).toExist();123 expect(retval.type).toBe(SELECT_VIEWPORT_SPATIAL_METHOD);124 });125 it('changeSpatialAttribute', () => {126 const attribute = "some value";127 const retval = changeSpatialAttribute(attribute);128 expect(retval).toExist();129 expect(retval.type).toBe(CHANGE_SPATIAL_ATTRIBUTE);130 expect(retval.attribute).toBe(attribute);131 });132 it('removeFilterField', () => {133 let rowId = 100;134 let retval = removeFilterField(rowId);135 expect(retval).toExist();136 expect(retval.type).toBe(REMOVE_FILTER_FIELD);137 expect(retval.rowId).toBe(100);138 });139 it('updateFilterField', () => {140 let rowId = 100;141 let fieldName = "fieldName";142 let fieldValue = "fieldValue";143 let retval = updateFilterField(rowId, fieldName, fieldValue);144 expect(retval).toExist();145 expect(retval.type).toBe(UPDATE_FILTER_FIELD);146 expect(retval.rowId).toBe(100);147 expect(retval.fieldName).toBe("fieldName");148 expect(retval.fieldValue).toBe("fieldValue");149 });150 it('updateExceptionField', () => {151 let rowId = 100;152 let message = "message";153 let retval = updateExceptionField(rowId, message);154 expect(retval).toExist();155 expect(retval.type).toBe(UPDATE_EXCEPTION_FIELD);156 expect(retval.rowId).toBe(100);157 expect(retval.exceptionMessage).toBe("message");158 });159 it('updateLogicCombo', () => {160 let groupId = 100;161 let logic = "OR";162 let retval = updateLogicCombo(groupId, logic);163 expect(retval).toExist();164 expect(retval.type).toBe(UPDATE_LOGIC_COMBO);165 expect(retval.groupId).toBe(100);166 expect(retval.logic).toBe("OR");167 });168 it('removeGroupField', () => {169 let groupId = 100;170 let retval = removeGroupField(groupId);171 expect(retval).toExist();172 expect(retval.type).toBe(REMOVE_GROUP_FIELD);173 expect(retval.groupId).toBe(100);174 });175 it('changeCascadingValue', () => {176 let attributes = [];177 let retval = changeCascadingValue(attributes);178 expect(retval).toExist();179 expect(retval.type).toBe(CHANGE_CASCADING_VALUE);180 expect(retval.attributes.length).toBe(0);181 });182 it('expandAttributeFilterPanel', () => {183 let expanded = false;184 let retval = expandAttributeFilterPanel(expanded);185 expect(retval).toExist();186 expect(retval.type).toBe(EXPAND_ATTRIBUTE_PANEL);187 expect(retval.expand).toBe(false);188 });189 it('expandSpatialFilterPanel', () => {190 let expanded = false;191 let retval = expandSpatialFilterPanel(expanded);192 expect(retval).toExist();193 expect(retval.type).toBe(EXPAND_SPATIAL_PANEL);194 expect(retval.expand).toBe(false);195 });196 it('selectSpatialMethod', () => {197 let method = "BBOX";198 let fieldName = "method";199 let retval = selectSpatialMethod(method, fieldName);200 expect(retval).toExist();201 expect(retval.type).toBe(SELECT_SPATIAL_METHOD);202 expect(retval.method).toBe("BBOX");203 expect(retval.fieldName).toBe("method");204 });205 it('selectSpatialOperation', () => {206 let operation = "DWITHIN";207 let fieldName = "operation";208 let retval = selectSpatialOperation(operation, fieldName);209 expect(retval).toExist();210 expect(retval.type).toBe(SELECT_SPATIAL_OPERATION);211 expect(retval.operation).toBe("DWITHIN");212 expect(retval.fieldName).toBe("operation");213 });214 it('removeSpatialSelection', () => {215 let retval = removeSpatialSelection();216 expect(retval).toExist();217 expect(retval.type).toBe(REMOVE_SPATIAL_SELECT);218 });219 it('showSpatialSelectionDetails', () => {220 let show = true;221 let retval = showSpatialSelectionDetails(show);222 expect(retval).toExist();223 expect(retval.type).toBe(SHOW_SPATIAL_DETAILS);224 expect(retval.show).toBe(true);225 });226 it('changeDwithinValue', () => {227 let retval = changeDwithinValue(1);228 expect(retval).toExist();229 expect(retval.type).toBe(CHANGE_DWITHIN_VALUE);230 expect(retval.distance).toBe(1);231 });232 it('query', () => {233 let retval = query("url", null);234 expect(retval).toExist();235 expect(retval.type).toBe(SHOW_GENERATED_FILTER);236 expect(retval.data).toBe(null);237 });238 it('search', () => {239 const retval = search("URL", {});240 expect(retval).toExist();241 expect(retval.type).toBe(QUERY_FORM_SEARCH);242 });243 it('loadFilter', () => {244 const filter = {245 };246 const retval = loadFilter(filter);247 expect(retval).toExist();248 expect(retval.type).toBe(LOAD_FILTER);249 expect(retval.filter).toBe(filter);250 });251 it('reset', () => {252 let retval = reset();253 expect(retval).toExist();254 expect(retval.type).toBe(QUERY_FORM_RESET);255 });256 it('resetZones', () => {257 let retval = resetZones();258 expect(retval).toExist();259 expect(retval.type).toBe(ZONES_RESET);260 });261 it('zoneFilter', () => {262 let retval = zoneFilter(null, 1);263 expect(retval).toExist();264 expect(retval.type).toBe(ZONE_FILTER);265 expect(retval.data).toBe(null);266 expect(retval.id).toBe(1);267 });268 it('zoneSearchError', () => {269 let retval = zoneSearchError("error");270 expect(retval).toExist();271 expect(retval.type).toBe(ZONE_SEARCH_ERROR);272 expect(retval.error).toBe("error");273 });274 it('zoneSearch', () => {275 let retval = zoneSearch(true, 1);276 expect(retval).toExist();277 expect(retval.type).toBe(ZONE_SEARCH);278 expect(retval.active).toBe(true);279 expect(retval.id).toBe(1);280 });281 it('loads an existing zones file', (done) => {282 zoneGetValues('../../test-resources/featureGrid-test-data.json')((e) => {283 try {284 expect(e).toExist();285 done();286 } catch (ex) {287 done(ex);288 }289 });290 });291 /* it('openMenu', () => {292 let retval = openMenu(true, 1);293 expect(retval).toExist();294 expect(retval.type).toBe(OPEN_MENU);295 expect(retval.active).toBe(true);296 expect(retval.id).toBe(1);297 });*/298 it('zoneChange', () => {299 let retval = zoneChange(1, "value");300 expect(retval).toExist();301 expect(retval.type).toBe(ZONE_CHANGE);302 expect(retval.value).toBe("value");303 expect(retval.id).toBe(1);304 });305 it('simpleFilterFieldUpdate', () => {306 let retval = simpleFilterFieldUpdate(1, "value");307 expect(retval).toExist();308 expect(retval.type).toBe(SIMPLE_FILTER_FIELD_UPDATE);309 expect(retval.properties).toBe("value");310 expect(retval.id).toBe(1);311 });312 it('addSimpleFilterField', () => {313 let retval = addSimpleFilterField("value");314 expect(retval).toExist();315 expect(retval.type).toBe(ADD_SIMPLE_FILTER_FIELD);316 expect(retval.properties).toBe("value");317 });318 it('removeSimpleFilterField', () => {319 let retval = removeSimpleFilterField(1);320 expect(retval).toExist();321 expect(retval.type).toBe(REMOVE_SIMPLE_FILTER_FIELD);322 expect(retval.id).toBe(1);323 });324 it('removeAllSimpleFilterFields', () => {325 let retval = removeAllSimpleFilterFields();326 expect(retval).toExist();327 expect(retval.type).toBe(REMOVE_ALL_SIMPLE_FILTER_FIELDS);328 });329 it('removeAllSimpleFilterFields', () => {330 const arg = {331 collectGeometries: {},332 options: {},333 feature: { geometry: {334 type: "Point",335 coordinates: [1, 1]336 }},337 srsName: {},338 style: {}339 };340 let retval = changeSpatialFilterValue(arg);341 expect(retval).toExist();342 expect(retval.type).toBe(CHANGE_SPATIAL_FILTER_VALUE);343 expect(retval.geometry).toBe(arg.feature.geometry);344 expect(retval.collectGeometries).toBe(arg.collectGeometries);345 expect(retval.options).toBe(arg.options);346 expect(retval.feature).toBe(arg.feature);347 expect(retval.srsName).toBe(arg.srsName);348 expect(retval.style).toBe(arg.style);349 });...

Full Screen

Full Screen

widgets-test.js

Source:widgets-test.js Github

copy

Full Screen

1/*2 * Copyright 2017, GeoSolutions Sas.3 * All rights reserved.4 *5 * This source code is licensed under the BSD-style license found in the6 * LICENSE file in the root directory of this source tree.7*/8import expect from 'expect';9import {10 NEW,11 INSERT,12 UPDATE,13 UPDATE_PROPERTY,14 UPDATE_LAYER,15 DELETE,16 CHANGE_LAYOUT,17 EDIT,18 EDIT_NEW,19 EDITOR_CHANGE,20 EDITOR_SETTING_CHANGE,21 DEFAULT_TARGET,22 OPEN_FILTER_EDITOR,23 EXPORT_CSV,24 EXPORT_IMAGE,25 DEPENDENCY_SELECTOR_KEY,26 TOGGLE_TRAY,27 TOGGLE_MAXIMIZE,28 createChart,29 NEW_CHART,30 exportCSV,31 exportImage,32 openFilterEditor,33 createWidget,34 insertWidget,35 updateWidget,36 updateWidgetProperty,37 updateWidgetLayer,38 deleteWidget,39 changeLayout,40 editWidget,41 editNewWidget,42 onEditorChange,43 changeEditorSetting,44 setPage,45 setupDependencySelector,46 toggleDependencySelector,47 toggleTray,48 toggleMaximize49} from '../widgets';50describe('Test correctness of the widgets actions', () => {51 it('exportCSV', () => {52 const data = [{a: "a"}];53 const retval = exportCSV({data, title: "TITLE"});54 expect(retval).toExist();55 expect(retval.type).toBe(EXPORT_CSV);56 expect(retval.data).toBe(data);57 expect(retval.title).toBe("TITLE");58 });59 it('exportImage', () => {60 const retval = exportImage({widgetDivId: "WIDGET"});61 expect(retval).toExist();62 expect(retval.type).toBe(EXPORT_IMAGE);63 expect(retval.widgetDivId).toBe("WIDGET");64 });65 it('openFilterEditor', () => {66 const retval = openFilterEditor();67 expect(retval).toExist();68 expect(retval.type).toBe(OPEN_FILTER_EDITOR);69 });70 it('createWidget', () => {71 const widget = {};72 const retval = createWidget(widget);73 expect(retval).toExist();74 expect(retval.type).toBe(NEW);75 expect(retval.widget).toBe(widget);76 });77 it('insertWidget', () => {78 const widget = {};79 const TARGET = "TARGET";80 const retval = insertWidget(widget, TARGET);81 expect(retval).toExist();82 expect(retval.type).toBe(INSERT);83 expect(retval.widget).toBe(widget);84 expect(retval.target).toBe(TARGET);85 const newval = insertWidget(widget);86 expect(newval.target).toBe(DEFAULT_TARGET);87 });88 it('updateWidget', () => {89 const widget = {};90 const retval = updateWidget(widget);91 expect(retval).toExist();92 expect(retval.type).toBe(UPDATE);93 expect(retval.widget).toBe(widget);94 expect(retval.target).toBe(DEFAULT_TARGET);95 });96 it('updateWidgetProperty', () => {97 const retval = updateWidgetProperty("id", "key", "value");98 expect(retval).toExist();99 expect(retval.type).toBe(UPDATE_PROPERTY);100 expect(retval.id).toBe("id");101 expect(retval.key).toBe("key");102 expect(retval.value).toBe("value");103 expect(retval.mode).toBe("replace");104 expect(retval.target).toBe(DEFAULT_TARGET);105 });106 it('updateWidgetLayer', () => {107 const layer = {id: "1", name: "layer1"};108 const retval = updateWidgetLayer(layer);109 expect(retval).toExist();110 expect(retval.type).toBe(UPDATE_LAYER);111 expect(retval.layer).toBe(layer);112 });113 it('deleteWidget', () => {114 const widget = {};115 const retval = deleteWidget(widget);116 expect(retval).toExist();117 expect(retval.type).toBe(DELETE);118 expect(retval.widget).toBe(widget);119 expect(retval.target).toBe(DEFAULT_TARGET);120 });121 it('changeLayout', () => {122 const layout = {};123 const allLayouts = {124 lg: {}125 };126 const retval = changeLayout(layout, allLayouts);127 expect(retval).toExist();128 expect(retval.layout).toBe(layout);129 expect(retval.allLayouts).toBe(allLayouts);130 expect(retval.type).toBe(CHANGE_LAYOUT);131 expect(retval.target).toBe(DEFAULT_TARGET);132 });133 it('editWidget', () => {134 const widget = {};135 const retval = editWidget(widget);136 expect(retval).toExist();137 expect(retval.type).toBe(EDIT);138 expect(retval.widget).toBe(widget);139 });140 it('editNewWidget', () => {141 const widget = {};142 const settings = {};143 const retval = editNewWidget(widget, settings);144 expect(retval).toExist();145 expect(retval.type).toBe(EDIT_NEW);146 expect(retval.widget).toBe(widget);147 expect(retval.settings).toBe(settings);148 });149 it('onEditorChange', () => {150 const key = "KEY";151 const value = "VALUE";152 const retval = onEditorChange(key, value);153 expect(retval).toExist();154 expect(retval.type).toBe(EDITOR_CHANGE);155 expect(retval.key).toBe(key);156 expect(retval.value).toBe(value);157 });158 it('changeEditorSetting', () => {159 const key = "KEY";160 const value = "VALUE";161 const retval = changeEditorSetting(key, value);162 expect(retval).toExist();163 expect(retval.type).toBe(EDITOR_SETTING_CHANGE);164 expect(retval.key).toBe(key);165 expect(retval.value).toBe(value);166 });167 it('setPage', () => {168 const retval = setPage(1);169 expect(retval).toExist();170 expect(retval.type).toBe(EDITOR_SETTING_CHANGE);171 expect(retval.key).toBe("step");172 expect(retval.value).toBe(1);173 });174 it('setupDependencySelector', () => {175 const value = { active: true, setup: "setup" };176 const retval = setupDependencySelector(value);177 expect(retval).toExist();178 expect(retval.type).toBe(EDITOR_SETTING_CHANGE);179 expect(retval.key).toBe(`${DEPENDENCY_SELECTOR_KEY}`);180 expect(retval.value).toBe(value);181 });182 it('toggleDependencySelector', () => {183 const value = { setup: "setup" };184 const retval = toggleDependencySelector(true, value);185 expect(retval).toExist();186 expect(retval.type).toBe(EDITOR_SETTING_CHANGE);187 expect(retval.key).toBe(`${DEPENDENCY_SELECTOR_KEY}`);188 expect(retval.value.setup).toBe("setup");189 expect(retval.value.active).toBe(true);190 });191 it('createChart', () => {192 const retval = createChart(true);193 expect(retval).toExist();194 expect(retval.type).toBe(NEW_CHART);195 });196 it('toggleTray', () => {197 const retval = toggleTray(true);198 expect(retval).toExist();199 expect(retval.type).toBe(TOGGLE_TRAY);200 expect(retval.value).toBe(true);201 });202 it('toggleMaximize', () => {203 const retval = toggleMaximize('widget', 'target');204 expect(retval).toExist();205 expect(retval.type).toBe(TOGGLE_MAXIMIZE);206 expect(retval.widget).toBe('widget');207 expect(retval.target).toBe('target');208 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data);7 });8});9{ statusCode: 400,10 data: { statusCode: 400, statusText: 'Bad Request' } }11wpt.runTest('www.google.com', function(err, data) {12wpt.runTest('www.google.com/', function(err, data) {13wpt.runTest('www.google.com/?gws_rd=ssl#q=webpagetest', function(err, data) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if(err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8var wpt = require('wpt');9 if(err) {10 console.log(err);11 } else {12 console.log(data);13 }14});15var wpt = require('wpt');16wpt.testLocation('Dulles:Chrome', function(err, data) {17 if(err) {18 console.log(err);19 } else {20 console.log(data);21 }22});23var wpt = require('wpt');24wpt.getLocations(function(err, data) {25 if(err) {26 console.log(err);27 } else {28 console.log(data);29 }30});31var wpt = require('wpt');32wpt.getTesters(function(err, data) {33 if(err) {34 console.log(err);35 } else {36 console.log(data);37 }38});39var wpt = require('wpt');40wpt.getTestStatus('1234567890', function(err, data) {41 if(err) {42 console.log(err);43 } else {44 console.log(data);45 }46});47var wpt = require('wpt');48wpt.getTestResults('1234567890', function(err, data) {49 if(err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55var wpt = require('wpt');56wpt.getTestResults('1234567890', {pagespeed: 1, requests: 1

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3test.runTest(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 test.getTestResults(data.data.testId, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14 });15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8var wpt = require('wpt');9promise.then(function (data) {10 console.log(data);11}, function (err) {12 console.log(err);13});14var wpt = require('wpt');15 if (err) {16 console.log(err);17 } else {18 console.log(data);19 }20});21var wpt = require('wpt');22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('wpt');29promise.then(function (data) {30 console.log(data);31}, function (err) {32 console.log(err);33});34var wpt = require('wpt');35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('wpt');42 if (err) {43 console.log(err);44 } else {45 console.log(data);46 }47});48var wpt = require('wpt');49promise.then(function (data) {50 console.log(data);51}, function (err) {52 console.log(err);53});

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.retval("Hello World");2wpt.retval("Hello World");3wpt.retval("Hello World");4wpt.retval("Hello World");5wpt.retval("Hello World");6wpt.retval("Hello World");7wpt.retval("Hello World");8wpt.retval("Hello World");9wpt.retval("Hello World");10wpt.retval("Hello World");11wpt.retval("Hello World");12wpt.retval("Hello World");13wpt.retval("Hello World");14wpt.retval("Hello World");15wpt.retval("Hello World");16wpt.retval("Hello World");17wpt.retval("Hello World");18wpt.retval("Hello World");19wpt.retval("Hello World");20wpt.retval("Hello World");21wpt.retval("Hello World");22wpt.retval("Hello World");23wpt.retval("Hello World");

Full Screen

Using AI Code Generation

copy

Full Screen

1var http = require('http');2var url = require('url');3var querystring = require('querystring');4var fs = require('fs');5var exec = require('child_process').exec;6var child;7var wpt = require('webpagetest');8var wpt = new wpt('www.webpagetest.org');9var options = {10};11wpt.runTest(testurl, options, function(err, data) {12 if (err) return console.error(err);13 console.log('Test submitted to WebPagetest for %s', testurl);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log('Test results for %s (%d runs)', testurl, data.data.runs);17 console.log('Average load time: %dms', data.data.average.firstView.loadTime);18 });19});20var http = require('http');21var url = require('url');22var querystring = require('querystring');23var fs = require('fs');24var exec = require('child_process').exec;25var child;26var wpt = require('webpagetest');27var wpt = new wpt('www.webpagetest.org');28var options = {29};30wpt.runTest(testurl, options, function(err, data) {31 if (err) return console.error(err);32 console.log('Test submitted to WebPagetest for %s', testurl);33 wpt.getTestResults(data.data.testId, function(err, data) {34 if (err) return console.error(err);35 console.log('Test results for %s (%d runs)', testurl, data.data.runs);36 console.log('Average load time: %dms', data.data.average.firstView.loadTime);37 });38});39var http = require('http');40var url = require('url');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptdriver = require('wptdriver');2var wptdriver = require('wptdriver');3var wptdriver = require('wptdriver');4var wptdriver = require('wptdriver');5var wptdriver = require('wptdriver');6var wptdriver = require('wptdriver');7var wptdriver = require('wptdriver');8var wptdriver = require('wptdriver');9var wptdriver = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var retval = require('retval');2var assert = require('assert');3var test = function(){4 assert.equal(1, 1);5 return retval;6}7module.exports = test;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful