Skip to content

Commit

Permalink
Move unit tests into time-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Oct 21, 2022
1 parent d8d0d31 commit dc79748
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
24 changes: 24 additions & 0 deletions test/time-cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,28 @@ describe('SimpleTimeCache', () => {
expect(timeCache.has('bFirst')).to.be.false()
expect(timeCache.has('cFirst')).to.be.false()
})

it('Map insertion order', () => {
const key1 = 'key1'
const key2 = 'key2'
const key3 = 'key3'

const map = new Map<string, number>()
map.set(key1, Date.now())
map.set(key2, Date.now())
map.set(key3, Date.now())

expect(Array.from(map.keys())).deep.equals([key1, key2, key3], 'Map iterator order')

// Does not change key position
map.set(key2, Date.now())

expect(Array.from(map.keys())).deep.equals([key1, key2, key3], 'Map iterator order after re-set')

// Changes key position
map.delete(key2)
map.set(key2, Date.now())

expect(Array.from(map.keys())).deep.equals([key1, key3, key2], 'Map iterator order after delete set')
})
})
27 changes: 0 additions & 27 deletions test/timeCache.spec.ts

This file was deleted.

0 comments on commit dc79748

Please sign in to comment.