mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Adding extensive typing support Unified browser and Node.JS implementations Adding support of Gitlab API 16.0
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import { Projects } from '../../../../src';
|
|
|
|
const { GITLAB_PERSONAL_ACCESS_TOKEN = '', GITLAB_URL = '', TEST_ID = Date.now() } = process.env;
|
|
|
|
let service: InstanceType<typeof Projects>;
|
|
|
|
beforeEach(() => {
|
|
service = new Projects({
|
|
host: GITLAB_URL,
|
|
token: GITLAB_PERSONAL_ACCESS_TOKEN,
|
|
});
|
|
});
|
|
|
|
describe('Projects.create', () => {
|
|
it('should create a valid project', async () => {
|
|
const name = `Project Creation Integration Test - NODEJS ${TEST_ID}`;
|
|
const p = await service.create({ name });
|
|
|
|
expect(p).toBeObject();
|
|
expect(p.name).toEqual(name);
|
|
});
|
|
});
|
|
|
|
describe('Projects.all', () => {
|
|
beforeAll(async () => {
|
|
const newProjects: any[] = [];
|
|
|
|
for (let i = 0; i < 10; i += 1) {
|
|
newProjects.push(
|
|
service.create({ name: `Project All Integration Test - NODEJS ${TEST_ID} ${i}` }),
|
|
);
|
|
}
|
|
|
|
await Promise.all(newProjects);
|
|
}, 20000);
|
|
|
|
it('should get 10 projects using offset pagination', async () => {
|
|
const projects = await service.all({
|
|
pagination: 'offset',
|
|
maxPages: 2,
|
|
perPage: 5,
|
|
simple: true,
|
|
});
|
|
|
|
expect(projects).toBeArray();
|
|
expect(projects).toHaveLength(10);
|
|
});
|
|
});
|
|
|
|
describe('Projects.upload', () => {
|
|
it('should upload a text file', async () => {
|
|
const project = await service.create({
|
|
name: `Project Upload Integration Test Text File - NodeJS ${TEST_ID}`,
|
|
});
|
|
|
|
const blob = new Blob(['TESTING FILE UPLOAD'], {
|
|
type: 'text/plain',
|
|
});
|
|
|
|
const results = await service.upload(project.id, { content: blob, filename: 'testfile.txt' });
|
|
|
|
expect(results).toContainKeys(['alt', 'url', 'full_path', 'markdown']);
|
|
});
|
|
});
|