Passed
Push — trunk ( 58a8b0...e62b2a )
by Christian
12:52 queued 13s
created

src/Administration/Resources/app/administration/src/app/service/user-activity.service.spec.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 34
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 19
mnd 0
bc 0
fnc 7
dl 0
loc 34
rs 10
bpm 0
cpm 1
noi 1
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;
5
6
    const cookieStorageMock = {};
7
    beforeEach(() => {
8
        Shopware.Service = () => {
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
9
            return {
10
                getStorage: () => {
11
                    return {
12
                        setItem(key, value) {
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