textarea.test.js 1.9 KB
Newer Older
张磊 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/

describe('component-native-textarea', () => {

  let page;
  let textarea;
  beforeAll(async () => {
    page = await program.reLaunch("/pages/component/textarea/textarea");
    await page.waitFor(3000);
    textarea = await page.$('.uni-textarea');
    await page.waitFor(1000);
  });

  it('focus', async () => {
15
    expect(await textarea.attribute("focus")).toBe("true")
张磊 已提交
16
    await page.setData({
17
      focus_boolean: false,
张磊 已提交
18 19
    })
    await page.waitFor(500)
20
    expect(await textarea.attribute("focus")).toBe("false")
张磊 已提交
21
  });
22
  it("auto-height", async () => {
张磊 已提交
23
    await page.setData({
24
      default_value: "",
张磊 已提交
25 26 27 28 29 30 31
      auto_height_boolean: true
    })
    await page.waitFor(500)
    var {
      width,
      height
    } = await textarea.size()
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
32
    expect(height).toBeLessThanOrEqual(200)
张磊 已提交
33
    await page.setData({
34 35
      default_value: "1\n2\n3\n4\n5\n6",
      auto_height_boolean: false
张磊 已提交
36 37 38 39 40 41
    })
    await page.waitFor(500)
    var {
      width,
      height
    } = await textarea.size()
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
42
    expect(height).toEqual(200)
43
  })
44 45 46 47 48
  it("cursor-color", async () => {
    await page.setData({
      cursor_color: "transparent",
    })
    await page.waitFor(500)
雪洛's avatar
雪洛 已提交
49
    expect(await textarea.attribute("cursor-color")).toBe("transparent")
50
  })
张磊 已提交
51 52 53 54 55 56

  it("inputmode", async () => {
    const inputmodeEnum = await page.data("inputmode_enum")
    for (var i = 0; i < inputmodeEnum.length; i++) {
      var x = inputmodeEnum[i]
      console.log(x['value'], x['name'])
57 58 59 60 61
      var selected = x['value'] - 1
      if(i == inputmodeEnum.length - 1){
        selected = i
      }
      await page.callMethod("radio_change_inputmode_enum", selected);
张磊 已提交
62
      await page.waitFor(500)
雪洛's avatar
雪洛 已提交
63
      expect(await textarea.attribute("inputmode")).toEqual(x['name'])
张磊 已提交
64 65 66 67
      await page.waitFor(500)
    }
  })
});