gitlab/test/test.ts

44 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-05-16 23:50:56 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2021-05-16 12:16:35 +00:00
import * as gitlab from '../ts/index';
2017-06-10 13:51:27 +00:00
2021-05-16 12:16:35 +00:00
let testGitlabAccount: gitlab.GitlabAccount;
2017-06-10 13:51:27 +00:00
2021-10-04 20:02:47 +00:00
const test1 = tap.test('should create an anonymous Gitlab Account', async () => {
2021-05-16 12:16:35 +00:00
testGitlabAccount = gitlab.GitlabAccount.createAnonymousAccount();
expect(testGitlabAccount).to.be.instanceOf(gitlab.GitlabAccount);
});
2021-10-04 20:02:47 +00:00
const test2 = tap.test('should get the pushrocks group', async () => {
2021-05-16 12:16:35 +00:00
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
console.log(pushrocksGroup);
});
2021-10-04 20:02:47 +00:00
const test3 = tap.test('should get the pushrocks group', async () => {
2021-05-16 12:16:35 +00:00
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
await pushrocksGroup.getProjects();
});
2021-10-04 20:02:47 +00:00
const test4 = tap.test('should get the readme of a project', async () => {
2021-05-16 23:50:56 +00:00
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
const projects = await pushrocksGroup.getProjects();
const selectedProject = projects.find((project) => {
return project.data?.name === 'smartfile';
});
expect(selectedProject.data.name).to.equal('smartfile');
const readme = await selectedProject.getReadmeAsMarkdown('master');
2021-10-04 20:02:47 +00:00
expect(readme.startsWith('# @pushrocks/smartfile')).to.be.true;
return projects;
2021-05-16 23:50:56 +00:00
});
2021-10-04 20:02:47 +00:00
const test5 = tap.test('should be able to create an article list', async () => {
const projects: gitlab.GitlabProject[] = (await test4.testResultPromise) as any;
for (const project of projects) {
console.log(await project.getProjectAsArticle());
}
})
2021-05-16 12:16:35 +00:00
tap.start();