From c8a8ecda8171ca2f3e7a44e760eb63b6bfe0695f Mon Sep 17 00:00:00 2001 From: Tyler Miller Date: Sat, 13 Jul 2024 17:27:02 -0700 Subject: [PATCH] test(hash): more tests for `lib.hash` --- test/github-theme/hash_spec.lua | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/test/github-theme/hash_spec.lua b/test/github-theme/hash_spec.lua index 1aeb6381..bb525c5d 100644 --- a/test/github-theme/hash_spec.lua +++ b/test/github-theme/hash_spec.lua @@ -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() @@ -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)