-
Notifications
You must be signed in to change notification settings - Fork 46
/
rxCharacterCount.page.js
148 lines (132 loc) · 3.84 KB
/
rxCharacterCount.page.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
var Page = require('astrolabe').Page;
/**
* @namespace
*/
var rxCharacterCount = {
eleParent: {
get: function () {
return this.rootElement.element(by.xpath('../..'));
}
},
lblRemaining: {
get: function () {
return this.eleParent.element(by.binding('remaining'));
}
},
txtComment: {
get: function () {
return this.rootElement;
},
},
/**
* @function
* @instance
* @description Whether the root element is currently displayed.
* @returns {Boolean}
*/
isDisplayed: {
value: function () {
return this.rootElement.isDisplayed();
}
},
/**
* @instance
* @description Get and set the comment's textual content. Will erase the current text when setting new text.
* @type {String}
* @example
* it('should erase all text and replace it with new text on update', function () {
* myPage.comment = 'Bar';
* expect(myPage.comment).to.eventually.equal('Bar');
* });
*/
comment: {
get: function () {
return this.txtComment.getAttribute('value');
},
set: function (text) {
this.txtComment.clear();
this.txtComment.sendKeys(text);
}
},
/**
* @instance
* @type {Number}
* @description The remaining number of characters that can be entered.
* @returns {Number}
*/
remaining: {
get: function () {
return this.lblRemaining.getText().then(parseInt);
}
},
/**
* @function
* @instance
* @description Whether or not the 'near-limit' class is displayed.
* @returns {Boolean}
*/
isNearLimit: {
value: function () {
return this.lblRemaining.getAttribute('class').then(function (classNames) {
return classNames.indexOf('near-limit') > -1;
});
}
},
/**
* @function
* @instance
* @description Whether or not the 'over-limit' class is displayed.
* @returns {Boolean}
*/
isOverLimit: {
value: function () {
return this.lblRemaining.getAttribute('class').then(function (classNames) {
return classNames.indexOf('over-limit') > -1;
});
}
},
/**
* @instance
* @type {String}
* @description The characters that are over the limit.
* @returns {String}
* @example
* // in this example, the limit of characters is 3
* myPage.comment = 'Anda Apine';
* expect(myPage.overLimitText).to.eventually.equal('a Apine');
*/
overLimitText: {
get: function () {
return this.eleParent.$('.over-limit-text').getText();
}
}
};
exports.rxCharacterCount = {
/**
* @function
* @memberof rxCharacterCount
* @description Creates a page object from an `[rx-bulk-select]` DOM element.
* @param {ElementFinder} [rxCharacterCountElement=$('[rx-character-count]')] -
* ElementFinder to be transformed into an {@link rxCharacterCount} object.
* @returns {rxCharacterCount}
*/
initialize: function (rxCharacterCountElement) {
rxCharacterCount.rootElement = {
get: function () { return rxCharacterCountElement; }
};
return Page.create(rxCharacterCount);
},
/**
* @memberof rxCharacterCount
* @deprecated
* @description Page object representing the first {@link rxCharacterCount} object found on the page.
* DEPRECATED: Use {@link rxCharacterCount.initialize} (without arguments) instead.
* @returns {rxCharacterCount}
*/
main: (function () {
rxCharacterCount.rootElement = {
get: function () { return $('[rx-character-count]'); }
};
return Page.create(rxCharacterCount);
})()
};