Skip to content

Commit

Permalink
fix: stories mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Dec 11, 2023
1 parent c0644b1 commit e9e255e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 66 deletions.
30 changes: 3 additions & 27 deletions src/stories/files/FileMockLoadingRepository.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { FileRepository } from '../../files/domain/repositories/FileRepository'
import { File } from '../../files/domain/models/File'
import { FilesCountInfo } from '../../files/domain/models/FilesCountInfo'
import { FileUserPermissions } from '../../files/domain/models/FileUserPermissions'
import { FileUserPermissionsMother } from '../../../tests/component/files/domain/models/FileUserPermissionsMother'
import { DatasetVersion } from '../../dataset/domain/models/Dataset'
import { FileCriteria } from '../../files/domain/models/FileCriteria'
import { FileMockRepository } from './FileMockRepository'

export class FileMockLoadingRepository implements FileRepository {
export class FileMockLoadingRepository extends FileMockRepository implements FileRepository {
getAllByDatasetPersistentId(
// eslint-disable-next-line unused-imports/no-unused-vars
datasetPersistentId: string,
Expand All @@ -26,35 +25,12 @@ export class FileMockLoadingRepository implements FileRepository {
// eslint-disable-next-line unused-imports/no-unused-vars
datasetVersion: DatasetVersion,
// eslint-disable-next-line unused-imports/no-unused-vars
criteria: FileCriteria
criteria?: FileCriteria
): Promise<FilesCountInfo> {
return new Promise(() => {
setTimeout(() => {
// Do nothing
}, 1000)
})
}
// eslint-disable-next-line unused-imports/no-unused-vars
getUserPermissionsById(id: number): Promise<FileUserPermissions> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(FileUserPermissionsMother.create())
}, 1000)
})
}

getFilesTotalDownloadSizeByDatasetPersistentId(
// eslint-disable-next-line unused-imports/no-unused-vars
datasetPersistentId: string,
// eslint-disable-next-line unused-imports/no-unused-vars
datasetVersion: DatasetVersion,
// eslint-disable-next-line unused-imports/no-unused-vars
criteria?: FileCriteria
): Promise<number> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(19900)
}, 1000)
})
}
}
14 changes: 2 additions & 12 deletions src/stories/files/FileMockNoDataRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { FileRepository } from '../../files/domain/repositories/FileRepository'
import { File } from '../../files/domain/models/File'
import { FilesCountInfo } from '../../files/domain/models/FilesCountInfo'
import { FilesCountInfoMother } from '../../../tests/component/files/domain/models/FilesCountInfoMother'
import { FileUserPermissions } from '../../files/domain/models/FileUserPermissions'
import { FileUserPermissionsMother } from '../../../tests/component/files/domain/models/FileUserPermissionsMother'
import { DatasetVersion } from '../../dataset/domain/models/Dataset'
import { FileCriteria } from '../../files/domain/models/FileCriteria'
import { FileMockRepository } from './FileMockRepository'

export class FileMockNoDataRepository implements FileRepository {
export class FileMockNoDataRepository extends FileMockRepository implements FileRepository {
getAllByDatasetPersistentId(
// eslint-disable-next-line unused-imports/no-unused-vars
datasetPersistentId: string,
Expand Down Expand Up @@ -48,13 +47,4 @@ export class FileMockNoDataRepository implements FileRepository {
}, 1000)
})
}

// eslint-disable-next-line unused-imports/no-unused-vars
getUserPermissionsById(id: number): Promise<FileUserPermissions> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(FileUserPermissionsMother.create())
}, 1000)
})
}
}
30 changes: 3 additions & 27 deletions src/stories/files/FileMockNoFiltersRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { File } from '../../files/domain/models/File'
import { FilesCountInfo } from '../../files/domain/models/FilesCountInfo'
import { FilesCountInfoMother } from '../../../tests/component/files/domain/models/FilesCountInfoMother'
import { FilesMockData } from './FileMockData'
import { FileUserPermissions } from '../../files/domain/models/FileUserPermissions'
import { FileUserPermissionsMother } from '../../../tests/component/files/domain/models/FileUserPermissionsMother'
import { DatasetVersion } from '../../dataset/domain/models/Dataset'
import { FileCriteria } from '../../files/domain/models/FileCriteria'
import { FileMockRepository } from './FileMockRepository'

export class FileMockNoFiltersRepository implements FileRepository {
export class FileMockNoFiltersRepository extends FileMockRepository implements FileRepository {
getAllByDatasetPersistentId(
// eslint-disable-next-line unused-imports/no-unused-vars
datasetPersistentId: string,
Expand All @@ -28,35 +27,12 @@ export class FileMockNoFiltersRepository implements FileRepository {
// eslint-disable-next-line unused-imports/no-unused-vars
datasetVersion: DatasetVersion,
// eslint-disable-next-line unused-imports/no-unused-vars
criteria: FileCriteria
criteria?: FileCriteria
): Promise<FilesCountInfo> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(FilesCountInfoMother.createOnlyTotal())
}, 1000)
})
}
// eslint-disable-next-line unused-imports/no-unused-vars
getUserPermissionsById(id: number): Promise<FileUserPermissions> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(FileUserPermissionsMother.create())
}, 1000)
})
}

getFilesTotalDownloadSizeByDatasetPersistentId(
// eslint-disable-next-line unused-imports/no-unused-vars
datasetPersistentId: string,
// eslint-disable-next-line unused-imports/no-unused-vars
datasetVersion: DatasetVersion,
// eslint-disable-next-line unused-imports/no-unused-vars
criteria?: FileCriteria
): Promise<number> {
return new Promise((resolve) => {
setTimeout(() => {
resolve(19900)
}, 1000)
})
}
}
6 changes: 6 additions & 0 deletions src/stories/files/FileMockRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FileUserPermissionsMother } from '../../../tests/component/files/domain
import { FileUserPermissions } from '../../files/domain/models/FileUserPermissions'
import { DatasetVersion } from '../../dataset/domain/models/Dataset'
import { FileCriteria } from '../../files/domain/models/FileCriteria'
import { FileMother } from '../../../tests/component/files/domain/models/FileMother'

export class FileMockRepository implements FileRepository {
// eslint-disable-next-line unused-imports/no-unused-vars
Expand Down Expand Up @@ -59,4 +60,9 @@ export class FileMockRepository implements FileRepository {
}, 1000)
})
}

// eslint-disable-next-line unused-imports/no-unused-vars
getMultipleFileDownloadUrl(ids: number[], downloadMode: string): string {
return FileMother.createDownloadUrl()
}
}

0 comments on commit e9e255e

Please sign in to comment.