Repository: spotify/backstage
File: packages/backend-defaults/src/entrypoints/cache/CacheManager.test.ts (TypeScript)

Code before:
          namespace: 'my-app',
          keyPrefixSeparator: '-',
        },
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('my-app-testPlugin');
    });

    it('uses default separator when keyPrefixSeparator is not provided (redis)', () => {
      const storeOptions = {
        type: 'redis',
        client: {
          namespace: 'my-app',
        },
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('my-app:testPlugin');
    });

    it('returns pluginId when store options have no keyPrefix (valkey)', () => {
      const storeOptions = {
        type: 'valkey',
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('testPlugin');
    });

    it('uses keyPrefix (valkey)', () => {
      const storeOptions = {
        type: 'valkey',
        client: {
          keyPrefix: 'my-app:',
        },
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('my-app:testPlugin');
    });

    it('handles empty namespace by falling back to pluginId', () => {

Review comment (suggestion):
Instead of copying and pasting the test which allows for them to get out of sync, could you parameterize the tests instead? This also makes it obvious that the tests are identical.

```js
it.each([
  { type: 'redis', suffix: 'namespace', client: { /* client here */ }],
  { type: 'valkey', suffix: 'keyPrefix', client: { /* client here */ }],
])('returns pluginid when store options have no $suffix ($type)', ({ client, type }) =>{
  const storeOptions = {
    client,
    type,
  };
  // ... the rest of the test is identical
});
```

This also applies to the next test you added.

Code after:
      );
      expect(result).toBe('my-app:testPlugin');
    });

    it('combines namespace and pluginId with custom separator for redis', () => {
      const storeOptions = {
        type: 'redis',
        client: {
          namespace: 'my-app',
          keyPrefixSeparator: '-',
        },
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('my-app-testPlugin');
    });

    it('uses default separator when keyPrefixSeparator is not provided for redis', () => {
      const storeOptions = {
        type: 'redis',
        client: {
          namespace: 'my-app',
        },
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('my-app:testPlugin');
    });

    it('uses keyPrefix for valkey', () => {
      const storeOptions = {
        type: 'valkey',
        client: {
          keyPrefix: 'my-app:',
        },
      };
      const result = (CacheManager as any).constructNamespace(
        'testPlugin',
        storeOptions,
      );
      expect(result).toBe('my-app:testPlugin');
    });

    it('handles empty namespace by falling back to pluginId', () => {
      const storeOptions = {
        client: {
          namespace: '',