|
|
@@ -1,5 +1,6 @@
|
|
|
import { describe, test, it, expect } from 'vitest'
|
|
|
import ObjectUtils from '~/services/utils/objectUtils'
|
|
|
+import StringUtils from '~/services/utils/stringUtils'
|
|
|
|
|
|
describe('cloneAndFlatten', () => {
|
|
|
test('If the object is already flat, it should return an identical object', () => {
|
|
|
@@ -88,3 +89,21 @@ describe('sortObjectsByKey', () => {
|
|
|
// expect(ObjectUtils.sortObjectsByKey({})).toThrowError('Expecting an object parameter')
|
|
|
// })
|
|
|
})
|
|
|
+
|
|
|
+describe('hash', () => {
|
|
|
+ test('empty object', async () => {
|
|
|
+ expect(await ObjectUtils.hash({})).toBe(
|
|
|
+ 'bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f',
|
|
|
+ )
|
|
|
+ })
|
|
|
+ test('simple object', async () => {
|
|
|
+ expect(await ObjectUtils.hash({ a: 1, b: 2, c: 3 })).toBe(
|
|
|
+ 'e7ec4a8f2309bdd4c4c57cb2adfb79c91a293597',
|
|
|
+ )
|
|
|
+ })
|
|
|
+ test('simple unsorted object', async () => {
|
|
|
+ expect(await ObjectUtils.hash({ b: 2, a: 1, c: 3 })).toBe(
|
|
|
+ 'e7ec4a8f2309bdd4c4c57cb2adfb79c91a293597',
|
|
|
+ )
|
|
|
+ })
|
|
|
+})
|