From 7ac51bb6f22427f6e608abbb2c91d4c39472c17e Mon Sep 17 00:00:00 2001 From: Dario Sechi Date: Wed, 27 Dec 2023 02:12:10 +0100 Subject: [PATCH] Update tests --- tests/modules/session-storage.test.ts | 56 ++++++++++++------------ tests/utils/element-utils.test.ts | 13 +----- tests/utils/slider-element-utils.test.ts | 2 +- 3 files changed, 30 insertions(+), 41 deletions(-) diff --git a/tests/modules/session-storage.test.ts b/tests/modules/session-storage.test.ts index 632a24b..c45f70b 100644 --- a/tests/modules/session-storage.test.ts +++ b/tests/modules/session-storage.test.ts @@ -2,48 +2,48 @@ import { beforeEach, describe, expect, it } from 'vitest' import { SessionStorage } from '../../src' describe('SessionStorage', () => { - beforeEach(async () => { - await SessionStorage.clear() + beforeEach(() => { + SessionStorage.clear() }) - it('clears', async () => { - await SessionStorage.set('person', {}) - expect(await SessionStorage.has('person')).toBeTruthy() - await SessionStorage.clear() - expect(await SessionStorage.has('person')).toBeFalsy() + it('clears', () => { + SessionStorage.set('person', {}) + expect(SessionStorage.has('person')).toBeTruthy() + SessionStorage.clear() + expect(SessionStorage.has('person')).toBeFalsy() }) - it('gets', async () => { - expect(await SessionStorage.get('person')).toStrictEqual({}) - await SessionStorage.set('person', { name: 'john' }) - expect(await SessionStorage.get('person')).toStrictEqual({ name: 'john' }) + it('gets', () => { + expect(SessionStorage.get('person')).toStrictEqual({}) + SessionStorage.set('person', { name: 'john' }) + expect(SessionStorage.get('person')).toStrictEqual({ name: 'john' }) }) - it('has', async () => { - await SessionStorage.set('person', {}) - expect(await SessionStorage.has('person')).toBeTruthy() + it('has', () => { + SessionStorage.set('person', {}) + expect(SessionStorage.has('person')).toBeTruthy() }) - it('removes', async () => { - await SessionStorage.set('person', {}) - expect(await SessionStorage.has('person')).toBeTruthy() - await SessionStorage.remove('person') - expect(await SessionStorage.has('person')).toBeFalsy() + it('removes', () => { + SessionStorage.set('person', {}) + expect(SessionStorage.has('person')).toBeTruthy() + SessionStorage.remove('person') + expect(SessionStorage.has('person')).toBeFalsy() }) - it('sets', async () => { - await SessionStorage.set('person', {}) - expect(await SessionStorage.has('person')).toBeTruthy() + it('sets', () => { + SessionStorage.set('person', {}) + expect(SessionStorage.has('person')).toBeTruthy() }) - it('does not throw if window is undefined', async () => { + it('does not throw if window is undefined', () => { // @ts-ignore delete global.window - expect(await SessionStorage.clear()).toBeUndefined() - expect(await SessionStorage.get('person')).toStrictEqual({}) - expect(await SessionStorage.has('person')).toBeFalsy() - expect(await SessionStorage.remove('person')).toBeUndefined() - expect(await SessionStorage.set('person', {})).toBeUndefined() + expect(SessionStorage.clear()).toBeUndefined() + expect(SessionStorage.get('person')).toStrictEqual({}) + expect(SessionStorage.has('person')).toBeFalsy() + expect(SessionStorage.remove('person')).toBeUndefined() + expect(SessionStorage.set('person', {})).toBeUndefined() }) }) diff --git a/tests/utils/element-utils.test.ts b/tests/utils/element-utils.test.ts index 241fcaf..ca36dda 100644 --- a/tests/utils/element-utils.test.ts +++ b/tests/utils/element-utils.test.ts @@ -1,11 +1,5 @@ import { beforeEach, describe, expect, it } from 'vitest' -import { - getElementStyleCompatibleValue, - joinElementClasses, - removeImmutableElementAttribute, - setElementAttribute, - setImmutableElementAttribute -} from '../../src' +import { getElementStyleCompatibleValue, removeImmutableElementAttribute, setElementAttribute, setImmutableElementAttribute } from '../../src' describe('Element Utils', () => { let element: HTMLDivElement @@ -14,11 +8,6 @@ describe('Element Utils', () => { element = document.createElement('div') }) - it('joins truthy element classes', () => { - expect(joinElementClasses('hello', 'world')).toBe('hello world') - expect(joinElementClasses('hello', false, 'world')).toBe('hello world') - }) - it('gets element style compatible value', () => { expect(getElementStyleCompatibleValue(0)).toBe('0px') expect(getElementStyleCompatibleValue('0')).toBe('0px') diff --git a/tests/utils/slider-element-utils.test.ts b/tests/utils/slider-element-utils.test.ts index babf419..b0415c9 100644 --- a/tests/utils/slider-element-utils.test.ts +++ b/tests/utils/slider-element-utils.test.ts @@ -11,6 +11,6 @@ describe('Slider Element Utils', () => { it('gets thumb element percentage', () => { expect(getSliderThumbElementPercentage()).toBe(0) - expect(getSliderThumbElementPercentage(25, 0, 100, 0)).toBe(25) + expect(getSliderThumbElementPercentage(25, { min: 0, max: 100, decimals: 0 })).toBe(25) }) })