Add additional tests around isAzurePipelinesAvailable

Signed-off-by: R-Beck-2020 <78100403+R-Beck-2020@users.noreply.github.com>
This commit is contained in:
R-Beck-2020
2024-01-10 14:11:32 +00:00
parent cb0afaad2b
commit 8c9f3a1e19
+81 -1
View File
@@ -13,10 +13,90 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { azureDevOpsPlugin } from './plugin';
import { Entity } from '@backstage/catalog-model';
import { azureDevOpsPlugin, isAzurePipelinesAvailable } from './plugin';
describe('azure-devops', () => {
it('should export plugin', () => {
expect(azureDevOpsPlugin).toBeDefined();
});
describe('isAzurePipelinesAvailable', () => {
it('should be true when project-repo annotation is present', () => {
const entity: Entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
namespace: 'default',
name: 'sample',
annotations: {
'dev.azure.com/project-repo': 'projectName/repoName',
},
},
};
expect(isAzurePipelinesAvailable(entity)).toBe(true);
});
it('should be true when project and build-definition annotation is present', () => {
const entity: Entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
namespace: 'default',
name: 'sample',
annotations: {
'dev.azure.com/project': 'projectName',
'dev.azure.com/build-definition': 'buildDefinitionName',
},
},
};
expect(isAzurePipelinesAvailable(entity)).toBe(true);
});
it('should be true when project-repo and build-definition annotation is present', () => {
const entity: Entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
namespace: 'default',
name: 'sample',
annotations: {
'dev.azure.com/project-repo': 'projectName/repoName',
'dev.azure.com/build-definition': 'buildDefinitionName',
},
},
};
expect(isAzurePipelinesAvailable(entity)).toBe(true);
});
it('should be false when only project annotation is present', () => {
const entity: Entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
namespace: 'default',
name: 'sample',
annotations: {
'dev.azure.com/project': 'projectName',
},
},
};
expect(isAzurePipelinesAvailable(entity)).toBe(false);
});
it('should be false when only build-definition annotation is present', () => {
const entity: Entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
namespace: 'default',
name: 'sample',
annotations: {
'dev.azure.com/build-definition': 'buildDefinitionName',
},
},
};
expect(isAzurePipelinesAvailable(entity)).toBe(false);
});
});
});