mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
migrate ui-components from flow to typescript
This commit is contained in:
@@ -1,98 +1,98 @@
|
||||
import { Repository } from '@scm-manager/ui-types';
|
||||
import { getProtocolLinkByType } from './repositories';
|
||||
import { Repository } from "@scm-manager/ui-types";
|
||||
import { getProtocolLinkByType } from "./repositories";
|
||||
|
||||
describe('getProtocolLinkByType tests', () => {
|
||||
it('should return the http protocol link', () => {
|
||||
describe("getProtocolLinkByType tests", () => {
|
||||
it("should return the http protocol link", () => {
|
||||
const repository: Repository = {
|
||||
namespace: 'scm',
|
||||
name: 'core',
|
||||
type: 'git',
|
||||
namespace: "scm",
|
||||
name: "core",
|
||||
type: "git",
|
||||
_links: {
|
||||
protocol: [
|
||||
{
|
||||
name: 'http',
|
||||
href: 'http://scm.scm-manager.org/repo/scm/core',
|
||||
},
|
||||
],
|
||||
},
|
||||
name: "http",
|
||||
href: "http://scm.scm-manager.org/repo/scm/core"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const link = getProtocolLinkByType(repository, 'http');
|
||||
expect(link).toBe('http://scm.scm-manager.org/repo/scm/core');
|
||||
const link = getProtocolLinkByType(repository, "http");
|
||||
expect(link).toBe("http://scm.scm-manager.org/repo/scm/core");
|
||||
});
|
||||
|
||||
it('should return the http protocol link from multiple protocols', () => {
|
||||
it("should return the http protocol link from multiple protocols", () => {
|
||||
const repository: Repository = {
|
||||
namespace: 'scm',
|
||||
name: 'core',
|
||||
type: 'git',
|
||||
namespace: "scm",
|
||||
name: "core",
|
||||
type: "git",
|
||||
_links: {
|
||||
protocol: [
|
||||
{
|
||||
name: 'http',
|
||||
href: 'http://scm.scm-manager.org/repo/scm/core',
|
||||
name: "http",
|
||||
href: "http://scm.scm-manager.org/repo/scm/core"
|
||||
},
|
||||
{
|
||||
name: 'ssh',
|
||||
href: 'git@scm.scm-manager.org:scm/core',
|
||||
},
|
||||
],
|
||||
},
|
||||
name: "ssh",
|
||||
href: "git@scm.scm-manager.org:scm/core"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const link = getProtocolLinkByType(repository, 'http');
|
||||
expect(link).toBe('http://scm.scm-manager.org/repo/scm/core');
|
||||
const link = getProtocolLinkByType(repository, "http");
|
||||
expect(link).toBe("http://scm.scm-manager.org/repo/scm/core");
|
||||
});
|
||||
|
||||
it('should return the http protocol, even if the protocol is a single link', () => {
|
||||
it("should return the http protocol, even if the protocol is a single link", () => {
|
||||
const repository: Repository = {
|
||||
namespace: 'scm',
|
||||
name: 'core',
|
||||
type: 'git',
|
||||
namespace: "scm",
|
||||
name: "core",
|
||||
type: "git",
|
||||
_links: {
|
||||
protocol: {
|
||||
name: 'http',
|
||||
href: 'http://scm.scm-manager.org/repo/scm/core',
|
||||
},
|
||||
},
|
||||
name: "http",
|
||||
href: "http://scm.scm-manager.org/repo/scm/core"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const link = getProtocolLinkByType(repository, 'http');
|
||||
expect(link).toBe('http://scm.scm-manager.org/repo/scm/core');
|
||||
const link = getProtocolLinkByType(repository, "http");
|
||||
expect(link).toBe("http://scm.scm-manager.org/repo/scm/core");
|
||||
});
|
||||
|
||||
it('should return null, if such a protocol does not exists', () => {
|
||||
it("should return null, if such a protocol does not exists", () => {
|
||||
const repository: Repository = {
|
||||
namespace: 'scm',
|
||||
name: 'core',
|
||||
type: 'git',
|
||||
namespace: "scm",
|
||||
name: "core",
|
||||
type: "git",
|
||||
_links: {
|
||||
protocol: [
|
||||
{
|
||||
name: 'http',
|
||||
href: 'http://scm.scm-manager.org/repo/scm/core',
|
||||
name: "http",
|
||||
href: "http://scm.scm-manager.org/repo/scm/core"
|
||||
},
|
||||
{
|
||||
name: 'ssh',
|
||||
href: 'git@scm.scm-manager.org:scm/core',
|
||||
},
|
||||
],
|
||||
},
|
||||
name: "ssh",
|
||||
href: "git@scm.scm-manager.org:scm/core"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const link = getProtocolLinkByType(repository, 'awesome');
|
||||
const link = getProtocolLinkByType(repository, "awesome");
|
||||
expect(link).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null, if no protocols are available', () => {
|
||||
it("should return null, if no protocols are available", () => {
|
||||
const repository: Repository = {
|
||||
namespace: 'scm',
|
||||
name: 'core',
|
||||
type: 'git',
|
||||
_links: {},
|
||||
namespace: "scm",
|
||||
name: "core",
|
||||
type: "git",
|
||||
_links: {}
|
||||
};
|
||||
|
||||
const link = getProtocolLinkByType(repository, 'http');
|
||||
const link = getProtocolLinkByType(repository, "http");
|
||||
expect(link).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user