Skip to content
/ Mulberry Public

🫐 Single-file Lua BDD library for testing Neovim plugins

License

Notifications You must be signed in to change notification settings

b0o/Mulberry

Repository files navigation

Mulberry license: MIT Test Status

Mulberry is a single-file Lua BDD library for testing Neovim plugins. Its goal is to make testing your plugins as easy and delicious as possible.

An example Mulberry test suite:

Describe("the awesome foobar plugin", function()
  It("can do the foo.do", function()
    local foo = require'foo'
    local myFoo = { lol: 'wut', yes: 'no' }
    local bar = foo.do(myFoo)
    Expect(bar).To.Be.A.ListLike()
  end)

  It("can foo.bar all the things", function()
    local foo = require'foo'
    local bar = foo.bar({ allTheThings: true })

    Expect(bar).To.HaveFieldPaths({
      { 'theThings.allOfThem[1].description', Which.Is.A.String   },
      { 'theThings.allOfThem[1].items',       Which.Is.A.ListLike },
      { 'theThings.allOfThem[1].name',        Which.Is.A.String   },
      { 'theThings.allOfThem[1].url',         Which.Is.A.String   },
      { 'theThings.allOfThem[1].enabled',     Which.Is.True       },
    })
  end)

  It("doesn't go meta on you", function()
    local foo = require'foo'
    Expect(foo).To.Not.HaveMetatable()
  end)

  It("always calls you back", function()
    local foo = require'foo'
    Expect(foo.someFooFunction).To.EvaluateTo(0xF00)
  end)
end)

Changelog

v0.0.3                                                                2023-07-31
  fix: ensure ListLike and DictLike values are tables
  fix: implement list_contains for nvim < v0.10
v0.0.2                                                                2023-07-31
  fix: matchers.In should check for existence of keys, not values

License

© 2021-2023 Maddison Hellstrom

Released under the MIT License.