@open-mercato/cache 0.10.1-develop.7786.1.g3645046322 → 0.10.1-develop.7792.1.b0ce6289cf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cache",
3
- "version": "0.10.1-develop.7786.1.g3645046322",
3
+ "version": "0.10.1-develop.7792.1.b0ce6289cf",
4
4
  "license": "MIT",
5
5
  "description": "Multi-strategy cache service with tag-based invalidation support",
6
6
  "type": "module",
@@ -46,16 +46,22 @@ describe('Cache Service', () => {
46
46
  })
47
47
 
48
48
  it('should respect defaultTtl option', async () => {
49
+ const initialTime = 1_000_000
50
+ const now = jest.spyOn(Date, 'now').mockReturnValue(initialTime)
49
51
  const cache = createCacheService({
50
52
  strategy: 'memory',
51
53
  defaultTtl: 100
52
54
  })
53
-
54
- await cache.set('test', 'value') // Should use default TTL
55
- expect(await cache.get('test')).toBe('value')
56
-
57
- await new Promise((resolve) => setTimeout(resolve, 150))
58
- expect(await cache.get('test')).toBeNull()
55
+
56
+ try {
57
+ await cache.set('test', 'value') // Should use default TTL
58
+ expect(await cache.get('test')).toBe('value')
59
+
60
+ now.mockReturnValue(initialTime + 101)
61
+ expect(await cache.get('test')).toBeNull()
62
+ } finally {
63
+ now.mockRestore()
64
+ }
59
65
  })
60
66
 
61
67
  it('should keep file-backed cache defaults under .mercato', async () => {