|
1 | 1 | var Lib = require('@src/lib'); |
2 | | -var Plots = require('@src/plots/plots'); |
| 2 | +var setCursor = require('@src/lib/setcursor'); |
| 3 | + |
| 4 | +var d3 = require('d3'); |
| 5 | +var PlotlyInternal = require('@src/plotly'); |
| 6 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 7 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
| 8 | +var Plots = PlotlyInternal.Plots; |
3 | 9 |
|
4 | 10 |
|
5 | 11 | describe('Test lib.js:', function() { |
@@ -715,4 +721,53 @@ describe('Test lib.js:', function() { |
715 | 721 | }); |
716 | 722 | }); |
717 | 723 |
|
| 724 | + describe('setCursor', function() { |
| 725 | + |
| 726 | + beforeEach(function() { |
| 727 | + this.el3 = d3.select(createGraphDiv()); |
| 728 | + }); |
| 729 | + |
| 730 | + afterEach(destroyGraphDiv); |
| 731 | + |
| 732 | + it('should assign cursor- class', function() { |
| 733 | + setCursor(this.el3, 'one'); |
| 734 | + |
| 735 | + expect(this.el3.attr('class')).toEqual('cursor-one'); |
| 736 | + }); |
| 737 | + |
| 738 | + it('should assign cursor- class while present non-cursor- classes', function() { |
| 739 | + this.el3.classed('one', true); |
| 740 | + this.el3.classed('two', true); |
| 741 | + this.el3.classed('three', true); |
| 742 | + setCursor(this.el3, 'one'); |
| 743 | + |
| 744 | + expect(this.el3.attr('class')).toEqual('one two three cursor-one'); |
| 745 | + }); |
| 746 | + |
| 747 | + it('should update class from one cursor- class to another', function() { |
| 748 | + this.el3.classed('cursor-one', true); |
| 749 | + setCursor(this.el3, 'two'); |
| 750 | + |
| 751 | + expect(this.el3.attr('class')).toEqual('cursor-two'); |
| 752 | + }); |
| 753 | + |
| 754 | + it('should update multiple cursor- classes', function() { |
| 755 | + this.el3.classed('cursor-one', true); |
| 756 | + this.el3.classed('cursor-two', true); |
| 757 | + this.el3.classed('cursor-three', true); |
| 758 | + setCursor(this.el3, 'four'); |
| 759 | + |
| 760 | + expect(this.el3.attr('class')).toEqual('cursor-four'); |
| 761 | + }); |
| 762 | + |
| 763 | + it('should remove cursor- if no new class is given', function() { |
| 764 | + this.el3.classed('cursor-one', true); |
| 765 | + this.el3.classed('cursor-two', true); |
| 766 | + this.el3.classed('cursor-three', true); |
| 767 | + setCursor(this.el3); |
| 768 | + |
| 769 | + expect(this.el3.attr('class')).toEqual(''); |
| 770 | + }); |
| 771 | + }); |
| 772 | + |
718 | 773 | }); |
0 commit comments