-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
33.attributes.test.js
66 lines (53 loc) · 2.42 KB
/
33.attributes.test.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
const jestExpect = require('expect');
describe('Attributes', () => {
const expectedText = 'TextView';
beforeEach(async () => {
await device.reloadReactNative();
await element(by.text('Attributes')).tap();
});
it('should get common attributes for view', async () => {
const attribs = await element(by.id('viewId')).getAttributes();
jestExpect(attribs.visible).toBe(true);
jestExpect(attribs.enabled).toBe(true);
});
it(':android: should get attributes for view', async () => {
const attribs = await element(by.id('viewId')).getAttributes();
jestExpect(attribs.alpha).toBe(1);
jestExpect(attribs.visibility).toBe("visible");
jestExpect(attribs.elevation).toBe(0);
jestExpect(attribs.height).toBe(263);
jestExpect(attribs.width).toBe(263);
jestExpect(attribs.focused).toBe(false);
});
it('should get common attributes for simple text', async () => {
const attribs = await element(by.id('textViewId')).getAttributes();
jestExpect(attribs.text).toBe(expectedText);
jestExpect(attribs.label).toBe(expectedText);
});
it(':android: should get attributes for simple text', async () => {
const attribs = await element(by.id('textViewId')).getAttributes();
jestExpect(attribs.text).toBe(expectedText);
jestExpect(attribs.length).toBe(expectedText.length);
jestExpect(attribs.textSize).toBe(37.0);
});
it(':android: should get attributes for text-input', async () => {
let attribs = await element(by.id('blurredTextInputId')).getAttributes();
jestExpect(attribs.focused).toEqual(false);
jestExpect(attribs.text).toEqual('blurred');
attribs = await element(by.id('focusedTextInputId')).getAttributes();
jestExpect(attribs.focused).toEqual(true);
jestExpect(attribs.text).toEqual('focused');
jestExpect(attribs.placeholder).toEqual('palace-holder');
});
it(':android: should get attributes for checkbox', async () => {
let attribs = await element(by.id('checkboxId')).getAttributes();
jestExpect(attribs.value).toBe(false);
await element(by.id('checkboxId')).tap();
attribs = await element(by.id('checkboxId')).getAttributes();
jestExpect(attribs.value).toBe(true);
});
it(':android: should get attributes for slider', async () => {
const attribs = await element(by.id('sliderId')).getAttributes();
jestExpect(attribs.value).toEqual(0.5 * 128); // Why 1 is 128 in RN? I'm not sure... maybe px vs. dp?! :shrug:
});
});