|
1 | | -describe("Delete Specifications", function() { |
2 | | - var input; |
3 | | - |
4 | | - beforeEach(function(){ |
5 | | - input = |
6 | | - $("<input />") |
7 | | - .appendTo("body"); |
| 1 | +feature("Deleting characters", function() { |
| 2 | + scenario('Hitting delete key with cursor on a mask literal',function(){ |
| 3 | + given("an input with a mask definition of '9-99'", function(){ |
| 4 | + input |
| 5 | + .mask("9-99") |
| 6 | + .mashKeys("123") |
| 7 | + |
| 8 | + }); |
| 9 | + |
| 10 | + given("the input has cursor positioned on literal", function(){ |
| 11 | + input |
| 12 | + .caret(1); |
| 13 | + }); |
| 14 | + when("hitting the delete key",function(){ |
| 15 | + input.mashKeys(function(keys){keys.type(keys.delete)}); |
| 16 | + }); |
| 17 | + |
| 18 | + then("value should be correct",function(){ |
| 19 | + expect(input).toHaveValue('1-3_'); |
| 20 | + }); |
| 21 | + |
| 22 | + and("caret position should be correct",function(){ |
| 23 | + expect(input.caret().begin).toEqual(2); |
| 24 | + }); |
8 | 25 | }); |
9 | | - |
10 | | - afterEach(function(){ |
11 | | - input.remove(); |
12 | | - }); |
13 | | - |
| 26 | +}); |
| 27 | + |
| 28 | + |
| 29 | +describe("Delete Specifications", function() { |
14 | 30 | describe("when deleting",function(){ |
15 | | - describe("with cursor is on a literal",function(){ |
16 | | - beforeEach(function(){ |
17 | | - runs(function(){ |
18 | | - input |
19 | | - .mask("9-99") |
20 | | - .focus(); |
21 | | - }); |
22 | | - waits(1); |
23 | | - runs(function(){ |
24 | | - input |
25 | | - .mashKeys("123") |
26 | | - .caret(1) |
27 | | - .mashKeys(function(keys){keys.type(keys.delete)}); |
28 | | - }); |
29 | | - }); |
30 | | - |
31 | | - it("should have the correct placeholder text", function(){ |
32 | | - expect(input).toHaveValue('1-3_'); |
33 | | - }); |
34 | | - |
35 | | - it("should have the correct caret position", function(){ |
36 | | - var caret=input.caret(); |
37 | | - expect(caret.begin).toEqual(2); |
38 | | - expect(caret.end).toEqual(2); |
39 | | - }); |
40 | | - }); |
41 | | - |
42 | | - |
43 | 31 | describe("with character to right of current position which matches current mask definition",function(){ |
44 | 32 | beforeEach(function(){ |
45 | 33 | input |
|
0 commit comments