diff --git a/src/Squidex/app/shared/services/backups.service.spec.ts b/src/Squidex/app/shared/services/backups.service.spec.ts index 11f7d81fe..9713a023a 100644 --- a/src/Squidex/app/shared/services/backups.service.spec.ts +++ b/src/Squidex/app/shared/services/backups.service.spec.ts @@ -16,6 +16,7 @@ import { BackupsService, DateTime, Resource, + ResourceLinks, RestoreDto } from '@app/shared/internal'; @@ -52,30 +53,16 @@ describe('BackupsService', () => { expect(req.request.headers.get('If-Match')).toBeNull(); req.flush({ - items: [{ - id: '1', - started: '2017-02-03', - stopped: '2017-02-04', - handledEvents: 13, - handledAssets: 17, - status: 'Failed', - _links: {} - }, - { - id: '2', - started: '2018-02-03', - stopped: null, - handledEvents: 23, - handledAssets: 27, - status: 'Completed', - _links: {} - }] + items: [ + backupResponse(12), + backupResponse(13) + ] }); expect(backups!).toEqual( new BackupsDto([ - new BackupDto({}, '1', DateTime.parseISO_UTC('2017-02-03'), DateTime.parseISO_UTC('2017-02-04'), 13, 17, 'Failed'), - new BackupDto({}, '2', DateTime.parseISO_UTC('2018-02-03'), null, 23, 27, 'Completed') + createBackup(12), + createBackup(13) ])); })); @@ -203,4 +190,32 @@ describe('BackupsService', () => { req.flush({}); })); -}); \ No newline at end of file + + function backupResponse(id: number) { + return { + id: `id${id}`, + started: `${id % 1000 + 2000}-12-12T10:10:00`, + stopped: id % 2 === 0 ? `${id % 1000 + 2000}-11-11T10:10:00` : null, + handledEvents: id * 17, + handledAssets: id * 23, + status: id % 2 === 0 ? 'Status' : 'Failed', + _links: { + download: { method: 'GET', href: '/api/backups/1' } + } + }; + } +}); + +export function createBackup(id: number) { + const links: ResourceLinks = { + download: { method: 'GET', href: '/api/backups/1' } + }; + + return new BackupDto(links, + `id${id}`, + DateTime.parseISO_UTC(`${id % 1000 + 2000}-12-12T10:10:00`), + id % 2 === 0 ? DateTime.parseISO_UTC(`${id % 1000 + 2000}-11-11T10:10:00`) : null, + id * 17, + id * 23, + id % 2 === 0 ? 'Status' : 'Failed'); +} \ No newline at end of file diff --git a/src/Squidex/app/shared/state/backups.state.spec.ts b/src/Squidex/app/shared/state/backups.state.spec.ts index 948589f35..22d5bb952 100644 --- a/src/Squidex/app/shared/state/backups.state.spec.ts +++ b/src/Squidex/app/shared/state/backups.state.spec.ts @@ -10,24 +10,24 @@ import { onErrorResumeNext } from 'rxjs/operators'; import { IMock, It, Mock, Times } from 'typemoq'; import { - BackupDto, BackupsDto, BackupsService, BackupsState, - DateTime, DialogService } from '@app/shared/internal'; import { TestValues } from './_test-helpers'; +import { createBackup } from './../services/backups.service.spec'; + describe('BackupsState', () => { const { app, appsState } = TestValues; - const backup1 = new BackupDto({}, 'id1', DateTime.now(), null, 1, 1, 'Started'); - const backup2 = new BackupDto({}, 'id2', DateTime.now(), null, 2, 2, 'Started'); + const backup1 = createBackup(12); + const backup2 = createBackup(13); let dialogs: IMock; let backupsService: IMock;