---@diagnostic disable: undefined-field
---@diagnostic disable: undefined-global

local ft = function(name)
    return vim.filetype.match { filename = name } or ""
end

describe('filetype detection:', function()
    it('extension: .log', function()
        assert.are.equal('log', ft('test.log'))
    end)
    it('extension: _log (x)', function()
        assert.are_not.equal('log', ft('test_log'))
    end)
    it('filename: custom', function()
        assert.are.equal('log', ft('syslog'))
    end)
    it('filename: custom (x)', function()
        assert.are_not.equal('log', ft('syslog1'))
    end)
    it('pattern: path', function()
        assert.are.equal('log', ft('/var/log/fake.txt'))
    end)
    it('pattern: wildcard', function()
        assert.are.equal('log', ft('wildcard.fake'))
    end)
    it('pattern: extension', function()
        assert.are.equal('log', ft('fake.ext'))
    end)
    it('pattern: special chars', function()
        assert.are.equal('log', ft('-#$&*'))
    end)
    it('pattern: uppercase', function()
        assert.are.equal('log', ft('fake.UPPERCASE'))
    end)
    it('pattern: uppercase (x)', function()
        assert.are_not.equal('log', ft('fake.Uppercase'))
    end)
end)
