⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
core
/
specs
/
View File Name :
impression_srv.test.ts
const mockBackendSrv = jest.fn(); import impressionSrv from '../services/impression_srv'; jest.mock('@grafana/runtime', () => { const originalRuntime = jest.requireActual('@grafana/runtime'); return { ...originalRuntime, getBackendSrv: mockBackendSrv, config: { ...originalRuntime.config, bootData: { ...originalRuntime.config.bootData, user: { ...originalRuntime.config.bootData.user, orgId: 'testOrgId', }, }, }, }; }); describe('ImpressionSrv', () => { beforeEach(() => { window.localStorage.removeItem(impressionSrv.impressionKey()); }); describe('getDashboardOpened', () => { it('should return list of dashboard uids', async () => { window.localStorage.setItem(impressionSrv.impressionKey(), JSON.stringify(['five', 'four', 1, 2, 3])); mockBackendSrv.mockImplementation(() => ({ get: jest.fn().mockResolvedValue(['one', 'two', 'three']) })); const result1 = await impressionSrv.getDashboardOpened(); expect(result1).toEqual(['five', 'four', 'one', 'two', 'three']); window.localStorage.setItem(impressionSrv.impressionKey(), JSON.stringify(['three', 'four'])); const result2 = await impressionSrv.getDashboardOpened(); expect(result2).toEqual(['three', 'four']); window.localStorage.setItem(impressionSrv.impressionKey(), JSON.stringify([1, 2, 3])); mockBackendSrv.mockImplementation(() => ({ get: jest.fn().mockResolvedValue(['one', 'two', 'three']) })); const result3 = await impressionSrv.getDashboardOpened(); expect(result3).toEqual(['one', 'two', 'three']); }); }); });