|
1 | 1 | var Lib = require('@src/lib');
|
2 | 2 | var setCursor = require('@src/lib/setcursor');
|
| 3 | +var overrideCursor = require('@src/lib/override_cursor'); |
3 | 4 |
|
4 | 5 | var d3 = require('d3');
|
5 | 6 | var Plotly = require('@lib');
|
@@ -1191,6 +1192,56 @@ describe('Test lib.js:', function() {
|
1191 | 1192 | });
|
1192 | 1193 | });
|
1193 | 1194 |
|
| 1195 | + describe('overrideCursor', function() { |
| 1196 | + |
| 1197 | + beforeEach(function() { |
| 1198 | + this.el3 = d3.select(createGraphDiv()); |
| 1199 | + }); |
| 1200 | + |
| 1201 | + afterEach(destroyGraphDiv); |
| 1202 | + |
| 1203 | + it('should apply the new cursor(s) and revert to the original when removed', function() { |
| 1204 | + this.el3 |
| 1205 | + .classed('cursor-before', true) |
| 1206 | + .classed('not-a-cursor', true) |
| 1207 | + .classed('another', true); |
| 1208 | + |
| 1209 | + overrideCursor(this.el3, 'after'); |
| 1210 | + expect(this.el3.attr('class')).toBe('not-a-cursor another cursor-after'); |
| 1211 | + |
| 1212 | + overrideCursor(this.el3, 'later'); |
| 1213 | + expect(this.el3.attr('class')).toBe('not-a-cursor another cursor-later'); |
| 1214 | + |
| 1215 | + overrideCursor(this.el3); |
| 1216 | + expect(this.el3.attr('class')).toBe('not-a-cursor another cursor-before'); |
| 1217 | + }); |
| 1218 | + |
| 1219 | + it('should apply the new cursor(s) and revert to the none when removed', function() { |
| 1220 | + this.el3 |
| 1221 | + .classed('not-a-cursor', true) |
| 1222 | + .classed('another', true); |
| 1223 | + |
| 1224 | + overrideCursor(this.el3, 'after'); |
| 1225 | + expect(this.el3.attr('class')).toBe('not-a-cursor another cursor-after'); |
| 1226 | + |
| 1227 | + overrideCursor(this.el3, 'later'); |
| 1228 | + expect(this.el3.attr('class')).toBe('not-a-cursor another cursor-later'); |
| 1229 | + |
| 1230 | + overrideCursor(this.el3); |
| 1231 | + expect(this.el3.attr('class')).toBe('not-a-cursor another'); |
| 1232 | + }); |
| 1233 | + |
| 1234 | + it('should do nothing if no existing or new override is present', function() { |
| 1235 | + this.el3 |
| 1236 | + .classed('cursor-before', true) |
| 1237 | + .classed('not-a-cursor', true); |
| 1238 | + |
| 1239 | + overrideCursor(this.el3); |
| 1240 | + |
| 1241 | + expect(this.el3.attr('class')).toBe('cursor-before not-a-cursor'); |
| 1242 | + }); |
| 1243 | + }); |
| 1244 | + |
1194 | 1245 | describe('getTranslate', function() {
|
1195 | 1246 |
|
1196 | 1247 | it('should work with regular DOM elements', function() {
|
|
0 commit comments