| Total Complexity | 7 |
| Complexity/F | 1 |
| Lines of Code | 34 |
| Function Count | 7 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 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 = () => { |
||
|
|
|||
| 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 |
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.