mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 03:00:04 -03:30
add tests for getDocsBaseUrl util
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
export default function getDocsBaseUrl(config) {
|
||||
let version = 'latest';
|
||||
if (config?.license_info?.license_type !== 'open') {
|
||||
const licenseType = config?.license_info?.license_type;
|
||||
if (licenseType && licenseType !== 'open') {
|
||||
version = config?.version ? config.version.split('-')[0] : 'latest';
|
||||
}
|
||||
return `https://docs.ansible.com/ansible-tower/${version}`;
|
||||
|
||||
44
awx/ui_next/src/util/getDocsBaseUrl.test.js
Normal file
44
awx/ui_next/src/util/getDocsBaseUrl.test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import getDocsBaseUrl from './getDocsBaseUrl';
|
||||
|
||||
describe('getDocsBaseUrl', () => {
|
||||
it('should return latest version for open license', () => {
|
||||
const result = getDocsBaseUrl({
|
||||
license_info: {
|
||||
license_type: 'open',
|
||||
},
|
||||
version: '18.0.0',
|
||||
});
|
||||
|
||||
expect(result).toEqual('https://docs.ansible.com/ansible-tower/latest');
|
||||
});
|
||||
|
||||
it('should return current version for enterprise license', () => {
|
||||
const result = getDocsBaseUrl({
|
||||
license_info: {
|
||||
license_type: 'enterprise',
|
||||
},
|
||||
version: '4.0.0',
|
||||
});
|
||||
|
||||
expect(result).toEqual('https://docs.ansible.com/ansible-tower/4.0.0');
|
||||
});
|
||||
|
||||
it('should strip version info after hyphen', () => {
|
||||
const result = getDocsBaseUrl({
|
||||
license_info: {
|
||||
license_type: 'enterprise',
|
||||
},
|
||||
version: '4.0.0-beta',
|
||||
});
|
||||
|
||||
expect(result).toEqual('https://docs.ansible.com/ansible-tower/4.0.0');
|
||||
});
|
||||
|
||||
it('should return latest version if license info missing', () => {
|
||||
const result = getDocsBaseUrl({
|
||||
version: '18.0.0',
|
||||
});
|
||||
|
||||
expect(result).toEqual('https://docs.ansible.com/ansible-tower/latest');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user