mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 11:19:10 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { CreateLibraryDto, LibraryResponseDto, ScanLibraryDto } from 'src/dtos/library.dto';
 | 
						|
import request from 'supertest';
 | 
						|
 | 
						|
export const libraryApi = {
 | 
						|
  getAll: async (server: any, accessToken: string) => {
 | 
						|
    const { body, status } = await request(server).get(`/library/`).set('Authorization', `Bearer ${accessToken}`);
 | 
						|
    expect(status).toBe(200);
 | 
						|
    return body as LibraryResponseDto[];
 | 
						|
  },
 | 
						|
  create: async (server: any, accessToken: string, dto: CreateLibraryDto) => {
 | 
						|
    const { body, status } = await request(server)
 | 
						|
      .post(`/library/`)
 | 
						|
      .set('Authorization', `Bearer ${accessToken}`)
 | 
						|
      .send(dto);
 | 
						|
    expect(status).toBe(201);
 | 
						|
    return body as LibraryResponseDto;
 | 
						|
  },
 | 
						|
  setImportPaths: async (server: any, accessToken: string, id: string, importPaths: string[]) => {
 | 
						|
    const { body, status } = await request(server)
 | 
						|
      .put(`/library/${id}`)
 | 
						|
      .set('Authorization', `Bearer ${accessToken}`)
 | 
						|
      .send({ importPaths });
 | 
						|
    expect(status).toBe(200);
 | 
						|
    return body as LibraryResponseDto;
 | 
						|
  },
 | 
						|
  scanLibrary: async (server: any, accessToken: string, id: string, dto: ScanLibraryDto = {}) => {
 | 
						|
    const { status } = await request(server)
 | 
						|
      .post(`/library/${id}/scan`)
 | 
						|
      .set('Authorization', `Bearer ${accessToken}`)
 | 
						|
      .send(dto);
 | 
						|
    expect(status).toBe(204);
 | 
						|
  },
 | 
						|
};
 |