Skip to content

Commit 8f0f075

Browse files
committed
🌴 uirevision tests
1 parent 21f5db5 commit 8f0f075

File tree

1 file changed

+55
-73
lines changed

1 file changed

+55
-73
lines changed

test/jasmine/tests/plot_api_react_test.js

Lines changed: 55 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,26 +1197,12 @@ describe('Plotly.react and uirevision attributes', function() {
11971197
};
11981198
}
11991199

1200-
function editModes() {
1201-
return Registry.call('_guiRelayout', gd, {
1202-
dragmode: 'pan',
1203-
hovermode: false,
1204-
'xaxis.showspikes': false,
1205-
'yaxis.showspikes': false,
1206-
'scene.dragmode': 'pan',
1207-
'scene.hovermode': false,
1208-
'scene.xaxis.showspikes': false,
1209-
'scene.yaxis.showspikes': false,
1210-
'scene.zaxis.showspikes': false
1211-
});
1212-
}
1213-
1214-
function _checkModes(original) {
1200+
function attrs(original) {
12151201
var dragmode = original ? 'zoom' : 'pan';
12161202
var hovermode = original ? 'closest' : false;
12171203
var spikes = original ? true : false;
12181204
var spikes3D = original ? [undefined, true] : false;
1219-
return checkState([], {
1205+
return {
12201206
dragmode: dragmode,
12211207
hovermode: hovermode,
12221208
'xaxis.showspikes': spikes,
@@ -1226,10 +1212,15 @@ describe('Plotly.react and uirevision attributes', function() {
12261212
'scene.xaxis.showspikes': spikes3D,
12271213
'scene.yaxis.showspikes': spikes3D,
12281214
'scene.zaxis.showspikes': spikes3D
1229-
});
1215+
};
12301216
}
1231-
var checkOriginalModes = _checkModes(true);
1232-
var checkEditedModes = _checkModes(false);
1217+
1218+
function editModes() {
1219+
return Registry.call('_guiRelayout', gd, attrs());
1220+
}
1221+
1222+
var checkOriginalModes = checkState([], attrs(true));
1223+
var checkEditedModes = checkState([], attrs());
12331224

12341225
_run(fig, editModes, checkOriginalModes, checkEditedModes).then(done);
12351226
});
@@ -1247,25 +1238,21 @@ describe('Plotly.react and uirevision attributes', function() {
12471238
};
12481239
}
12491240

1250-
function editView() {
1251-
return Registry.call('_guiRelayout', gd, {
1252-
'geo.projection.scale': 3,
1253-
'geo.projection.rotation.lon': -45,
1254-
'geo.center.lat': 22,
1255-
'geo.center.lon': -45
1256-
});
1257-
}
1258-
1259-
function _checkView(original) {
1260-
return checkState([], {
1241+
function attrs(original) {
1242+
return {
12611243
'geo.projection.scale': original ? [undefined, 1] : 3,
12621244
'geo.projection.rotation.lon': original ? [undefined, 0] : -45,
12631245
'geo.center.lat': original ? [undefined, 0] : 22,
12641246
'geo.center.lon': original ? [undefined, 0] : -45
1265-
});
1247+
};
1248+
}
1249+
1250+
function editView() {
1251+
return Registry.call('_guiRelayout', gd, attrs());
12661252
}
1267-
var checkOriginalView = _checkView(true);
1268-
var checkEditedView = _checkView(false);
1253+
1254+
var checkOriginalView = checkState([], attrs(true));
1255+
var checkEditedView = checkState([], attrs());
12691256

12701257
_run(fig, editView, checkOriginalView, checkEditedView).then(done);
12711258
});
@@ -1369,26 +1356,25 @@ describe('Plotly.react and uirevision attributes', function() {
13691356
};
13701357
}
13711358

1372-
function editPolar() {
1373-
return Registry.call('_guiRelayout', gd, {
1374-
'polar.radialaxis.range': [-2, 4],
1375-
'polar.radialaxis.angle': 45,
1376-
'polar.angularaxis.rotation': -90
1377-
});
1378-
}
1379-
1380-
function checkPolar(original) {
1381-
return checkState([], {
1359+
function attrs(original) {
1360+
return {
13821361
'polar.radialaxis.range[0]': original ? 0 : -2,
13831362
'polar.radialaxis.range[1]': original ? 2 : 4,
13841363
'polar.radialaxis.angle': original ? [undefined, 0] : 45,
13851364
'polar.angularaxis.rotation': original ? [undefined, 0] : -90
1386-
});
1365+
};
13871366
}
13881367

1389-
_run(fig, editPolar, checkPolar(true), checkPolar())
1368+
function editPolar() {
1369+
return Registry.call('_guiRelayout', gd, attrs());
1370+
}
1371+
1372+
var checkInitial = checkState([], attrs(true));
1373+
var checkEdited = checkState([], attrs());
1374+
1375+
_run(fig, editPolar, checkInitial, checkEdited)
13901376
.then(function() {
1391-
return _run(fig2, editPolar, checkPolar(true), checkPolar());
1377+
return _run(fig2, editPolar, checkInitial, checkEdited);
13921378
})
13931379
.then(done);
13941380
});
@@ -1418,25 +1404,24 @@ describe('Plotly.react and uirevision attributes', function() {
14181404
};
14191405
}
14201406

1421-
function editTernary() {
1422-
return Registry.call('_guiRelayout', gd, {
1423-
'ternary.aaxis.min': 0.1,
1424-
'ternary.baxis.min': 0.2,
1425-
'ternary.caxis.min': 0.3
1426-
});
1427-
}
1428-
1429-
function checkTernary(original) {
1430-
return checkState([], {
1407+
function attrs(original) {
1408+
return {
14311409
'ternary.aaxis.min': original ? [undefined, 0] : 0.1,
14321410
'ternary.baxis.min': original ? [undefined, 0] : 0.2,
14331411
'ternary.caxis.min': original ? [undefined, 0] : 0.3,
1434-
});
1412+
};
1413+
}
1414+
1415+
function editTernary() {
1416+
return Registry.call('_guiRelayout', gd, attrs());
14351417
}
14361418

1437-
_run(fig, editTernary, checkTernary(true), checkTernary())
1419+
var checkInitial = checkState([], attrs(true));
1420+
var checkEdited = checkState([], attrs());
1421+
1422+
_run(fig, editTernary, checkInitial, checkEdited)
14381423
.then(function() {
1439-
return _run(fig2, editTernary, checkTernary(true), checkTernary());
1424+
return _run(fig2, editTernary, checkInitial, checkEdited);
14401425
})
14411426
.then(done);
14421427
});
@@ -1452,31 +1437,28 @@ describe('Plotly.react and uirevision attributes', function() {
14521437
};
14531438
}
14541439

1455-
function editMap() {
1456-
return Registry.call('_guiRelayout', gd, {
1457-
'mapbox.center.lat': 1,
1458-
'mapbox.center.lon': 2,
1459-
'mapbox.zoom': 3,
1460-
'mapbox.bearing': 4,
1461-
'mapbox.pitch': 5
1462-
});
1463-
}
1464-
1465-
function checkMapbox(original) {
1466-
return checkState([], {
1440+
function attrs(original) {
1441+
return {
14671442
'mapbox.center.lat': original ? [undefined, 0] : 1,
14681443
'mapbox.center.lon': original ? [undefined, 0] : 2,
14691444
'mapbox.zoom': original ? [undefined, 1] : 3,
14701445
'mapbox.bearing': original ? [undefined, 0] : 4,
14711446
'mapbox.pitch': original ? [undefined, 0] : 5
1472-
});
1447+
};
1448+
}
1449+
1450+
function editMap() {
1451+
return Registry.call('_guiRelayout', gd, attrs());
14731452
}
14741453

1454+
var checkInitial = checkState([], attrs(true));
1455+
var checkEdited = checkState([], attrs());
1456+
14751457
Plotly.setPlotConfig({
14761458
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
14771459
});
14781460

1479-
_run(fig, editMap, checkMapbox(true), checkMapbox()).then(done);
1461+
_run(fig, editMap, checkInitial, checkEdited).then(done);
14801462
});
14811463

14821464
it('preserves editable: true shape & annotation edits using editrevision', function(done) {

0 commit comments

Comments
 (0)