Init.Spec.js
1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
feature("Initializing a Mask",function(){
scenario("An input with no value",function(){
given("an input with no value",function(){
input.val("");
});
when("setting a mask with two placeholders",function(){
input.mask("99");
});
then("the value should be an empty string",function(){
expect(input).toHaveValue("");
});
});
scenario("An input with a valid value and no placeholders remaining",function(){
given("an input with a valid value",function(){
input.val("5555555555");
});
when("setting a mask",function(){
input.mask("(999) 999-9999");
});
then("the value should be intact",function(){
expect(input).toHaveValue("(555) 555-5555");
});
});
scenario("An input with an invalid value and placeholders remaining",function(){
given("an invalid input value",function(){
input.val("55555555");
});
when("setting a mask",function(){
input.mask("(999) 999-9999");
});
then("the value should be empty",function(){
expect(input).toHaveValue("");
});
});
scenario("An input with an invalid value, placeholders remaining and autoclear set to false",function(){
given("an invalid input value",function(){
input.val("55555555");
});
when("setting a mask with autoclear set to false",function(){
input.mask("(999) 999-9999", { autoclear: false });
});
then("the value be intact with placeholders visible",function(){
expect(input).toHaveValue("(555) 555-55__");
});
});
scenario("An input no value and autoclear set to false", function() {
given("an input with no value",function(){
input.val("");
});
when("setting a mask with autoclear set to false",function(){
input.mask("(999) 999-9999", { autoclear: false });
});
then("the value should be empty",function(){
expect(input).toHaveValue("");
});
});
});