Passed
Push — 6.5.0.0 ( cc2046...54a049 )
by Christian
14:07 queued 13s
created

user-activity.service.spec.ts ➔ setItem   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
import UserActivityService from './user-activity.service';
2
3
describe('src/app/service/user-activity.service.ts', () => {
4
    let service: UserActivityService | undefined;
5
6
    const cookieStorageMock = {};
7
    beforeEach(() => {
8
        Shopware.Service = () => {
9
            return {
10
                getStorage: () => {
11
                    return {
12
                        setItem(key: string, value: unknown) {
13
                            cookieStorageMock[key] = value;
14
                        }
15
                    };
16
                }
17
            };
18
        };
19
        service = new UserActivityService();
20
    });
21
22
    it('should instantiate', () => {
23
        expect(service instanceof UserActivityService).toBe(true);
24
    });
25
26
    it('should change last user activity', () => {
27
        const date = new Date();
28
        const expectedResult = Math.round(+date / 1000);
29
30
        service.updateLastUserActivity(date);
31
        // @ts-expect-error
32
        expect(cookieStorageMock.lastActivity).toBe(`${expectedResult}`);
33
    });
34
});
35