]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | describe("Ext.slider.Tip", function() {\r |
2 | var slider, tip, thumb0, spaceEl,\r | |
3 | createSlider = function(config) {\r | |
4 | tip = new Ext.slider.Tip();\r | |
5 | \r | |
6 | spyOn(tip, "show").andCallThrough();\r | |
7 | spyOn(tip, "update").andCallThrough();\r | |
8 | \r | |
9 | // make enough room to display tip correctly\r | |
10 | spaceEl = Ext.getBody().createChild({});\r | |
11 | spaceEl.setHeight(100);\r | |
12 | slider = new Ext.slider.Single(Ext.apply({\r | |
13 | renderTo: Ext.getBody(),\r | |
14 | name: "test",\r | |
15 | width: 205,\r | |
16 | labelWidth: 0,\r | |
17 | minValue: 0,\r | |
18 | maxValue: 100,\r | |
19 | useTips: false,\r | |
20 | plugins: [tip],\r | |
21 | animate: false\r | |
22 | }, config));\r | |
23 | \r | |
24 | thumb0 = slider.thumbs[0];\r | |
25 | };\r | |
26 | \r | |
27 | afterEach(function() {\r | |
28 | if (slider) {\r | |
29 | slider.destroy();\r | |
30 | }\r | |
31 | spaceEl.destroy();\r | |
32 | slider = null;\r | |
33 | });\r | |
34 | \r | |
35 | describe("when thumb is dragged", function() {\r | |
36 | var thumbXY, thumbSize, tipXY, tipSize;\r | |
37 | beforeEach(function() {\r | |
38 | createSlider();\r | |
39 | var xy = thumb0.el.getXY();\r | |
40 | jasmine.fireMouseEvent(thumb0.el, 'mousedown', xy[0], xy[1] + 5);\r | |
41 | jasmine.fireMouseEvent(thumb0.el, 'mousemove', xy[0] + 50, xy[1] + 5);\r | |
42 | \r | |
43 | waitsFor(function() {\r | |
44 | return tip.el;\r | |
45 | });\r | |
46 | \r | |
47 | runs(function() {\r | |
48 | tipXY = tip.el.getXY();\r | |
49 | tipSize = tip.el.getSize();\r | |
50 | thumbXY = thumb0.el.getXY();\r | |
51 | thumbSize = thumb0.el.getSize();\r | |
52 | jasmine.fireMouseEvent(thumb0.el, 'mouseup', xy[0] + 50, xy[1] + 5);\r | |
53 | });\r | |
54 | });\r | |
55 | \r | |
56 | it("should show the tooltip", function() {\r | |
57 | expect(tip.show).toHaveBeenCalled();\r | |
58 | });\r | |
59 | \r | |
60 | it("should update the tooltip text", function() {\r | |
61 | expect(tip.update).toHaveBeenCalledWith(tip.getText(thumb0));\r | |
62 | });\r | |
63 | \r | |
64 | it("should align the tip to t-b?", function() {\r | |
65 | expect(tipXY[0] < thumbXY[0]).toBe(true);\r | |
66 | expect(tipXY[0] + tipSize.width > thumbXY[0] + thumbSize.width).toBe(true);\r | |
67 | expect(tipXY[1] - tip.offsets[1] + tipSize.height).toBe(thumbXY[1]);\r | |
68 | });\r | |
69 | \r | |
70 | });\r | |
71 | \r | |
72 | }); |