Skip to content

Commit

Permalink
test(hash): more tests for lib.hash
Browse files Browse the repository at this point in the history
  • Loading branch information
tmillr committed Jul 14, 2024
1 parent c23f71b commit c8a8ecd
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions test/github-theme/hash_spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local hash = require('github-theme.lib.hash')

describe('Hash', function()
describe('hash()', function()
it('should produce same result with different table order', function()
local t1 = { Normal = { bg = '#192330', fg = '#cdcecf' } }
local t2 = { Normal = { fg = '#cdcecf', bg = '#192330' } }
assert.is.same(hash(t1), hash(t2))
assert.same(hash(t1), hash(t2))
end)

it('should understand booleans', function()
Expand All @@ -30,6 +30,27 @@ describe('Hash', function()
search = false,
},
}
assert.is_not.same(hash(t1), hash(t2))
assert.not_same(hash(t1), hash(t2))
end)

it('should handle empty tables within (1)', function()
assert.not_same(hash({}), hash({ k = {} }))
assert.not_same(hash({}), hash({ key = {} }))
end)

-- TODO: FAILING
pending('should handle empty tables within (2)', function()
assert.not_same(hash({ k = 0 }), hash({ k = {} }))
assert.not_same(hash({ key = 0 }), hash({ key = {} }))
end)

it('should handle empty tables within (3)', function()
assert.not_same(hash({ k = '' }), hash({ k = {} }))
assert.not_same(hash({ key = '' }), hash({ key = {} }))
end)

it('should handle empty tables within (4)', function()
assert.not_same(hash({ k = false }), hash({ k = {} }))
assert.not_same(hash({ key = false }), hash({ key = {} }))
end)
end)

0 comments on commit c8a8ecd

Please sign in to comment.