repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/tests/std/string_spec.lua

Raw
local string = require('std.string')

describe('std.string', function()
  describe('is_blank', function()
    it('should return true for nil', function()
      assert.is_true(string.is_blank(nil))
    end)

    it('should return true for empty string', function()
      assert.is_true(string.is_blank(''))
    end)

    it('should return true for whitespace-only string', function()
      assert.is_true(string.is_blank('   '))
      assert.is_true(string.is_blank('\t'))
      assert.is_true(string.is_blank(' \t '))
    end)

    it('should return false for non-empty string', function()
      assert.is_false(string.is_blank('hello'))
    end)

    it('should return false for string with surrounding whitespace', function()
      assert.is_false(string.is_blank('  hello  '))
    end)
  end)
end)