aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/options_spec.lua
blob: bc72ca71aae410742bbbc696acd7b363b529fbf4 (plain) (blame)
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
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq

describe('ui receives option updates', function()
  local screen

  before_each(function()
    clear()
    screen = Screen.new(20,5)
    screen:attach()
  end)

  after_each(function()
    screen:detach()
  end)

  local defaults = {
    ambiwidth='single',
    arabicshape=true,
    emoji=true,
    guifont='',
    guifontset='',
    guifontwide='',
    linespace=0,
    showtabline=1,
    termguicolors=false,
  }

  it("for defaults", function()
    screen:expect(function()
      eq(defaults, screen.options)
    end)
  end)

  it("when setting options", function()
    local changed = {}
    for k,v in pairs(defaults) do
      changed[k] = v
    end

    command("set termguicolors")
    changed.termguicolors = true
    screen:expect(function()
      eq(changed, screen.options)
    end)

    command("set guifont=Comic\\ Sans")
    changed.guifont = "Comic Sans"
    screen:expect(function()
      eq(changed, screen.options)
    end)

    command("set showtabline=0")
    changed.showtabline = 0
    screen:expect(function()
      eq(changed, screen.options)
    end)

    command("set linespace=13")
    changed.linespace = 13
    screen:expect(function()
      eq(changed, screen.options)
    end)

    command("set linespace=-11")
    changed.linespace = -11
    screen:expect(function()
      eq(changed, screen.options)
    end)

    command("set all&")
    screen:expect(function()
      eq(defaults, screen.options)
    end)
  end)
end)