68 lines · 1.7 KB
local actions = require('biscuit.actions')

describe('biscuit.actions', function()
  before_each(function()
    require('biscuit').setup({ codes = { 'test_code' } })
  end)

  describe('code_matches (internal)', function()
    -- We can't directly test private functions, but we can test behavior
    -- through the public interface
  end)

  describe('apply_actions', function()
    it('should warn when no codes configured', function()
      require('biscuit').setup({ codes = {} })

      local notified = false
      local original_notify = vim.notify
      vim.notify = function(msg, level)
        if msg:find('No codes configured') then
          notified = true
        end
      end

      actions.apply_actions({})

      vim.notify = original_notify
      assert.is_true(notified)
    end)

    it('should accept codes from opts', function()
      require('biscuit').setup({ codes = {} })

      local notified_codes = nil
      local original_notify = vim.notify
      vim.notify = function(msg)
        local match = msg:match('codes: (.+)')
        if match then
          notified_codes = match
        end