Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alchemicas committed Dec 27, 2023
1 parent 2039c85 commit 7ac51bb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 41 deletions.
56 changes: 28 additions & 28 deletions tests/modules/session-storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
13 changes: 1 addition & 12 deletions tests/utils/element-utils.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/slider-element-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

0 comments on commit 7ac51bb

Please sign in to comment.