summaryrefslogtreecommitdiff
path: root/spec/frontend/packages/shared/components/package_path_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/packages/shared/components/package_path_spec.js')
-rw-r--r--spec/frontend/packages/shared/components/package_path_spec.js86
1 files changed, 52 insertions, 34 deletions
diff --git a/spec/frontend/packages/shared/components/package_path_spec.js b/spec/frontend/packages/shared/components/package_path_spec.js
index 3c9cd3387ba..edbdd55c1d7 100644
--- a/spec/frontend/packages/shared/components/package_path_spec.js
+++ b/spec/frontend/packages/shared/components/package_path_spec.js
@@ -39,48 +39,66 @@ describe('PackagePath', () => {
const pathPieces = path.split('/').slice(1);
const hasTooltip = shouldExist.includes(ELLIPSIS_ICON);
- beforeEach(() => {
- mountComponent({ path });
- });
+ describe('not disabled component', () => {
+ beforeEach(() => {
+ mountComponent({ path });
+ });
- it('should have a base icon', () => {
- expect(findItem(BASE_ICON).exists()).toBe(true);
- });
+ it('should have a base icon', () => {
+ expect(findItem(BASE_ICON).exists()).toBe(true);
+ });
- it('should have a root link', () => {
- const root = findItem(ROOT_LINK);
- expect(root.exists()).toBe(true);
- expect(root.attributes('href')).toBe(rootUrl);
- });
+ it('should have a root link', () => {
+ const root = findItem(ROOT_LINK);
+ expect(root.exists()).toBe(true);
+ expect(root.attributes('href')).toBe(rootUrl);
+ });
- if (hasTooltip) {
- it('should have a tooltip', () => {
- const tooltip = findTooltip(findItem(ELLIPSIS_ICON));
- expect(tooltip).toBeDefined();
- expect(tooltip.value).toMatchObject({
- title: path,
+ if (hasTooltip) {
+ it('should have a tooltip', () => {
+ const tooltip = findTooltip(findItem(ELLIPSIS_ICON));
+ expect(tooltip).toBeDefined();
+ expect(tooltip.value).toMatchObject({
+ title: path,
+ });
});
- });
- }
+ }
- if (shouldExist.length) {
- it.each(shouldExist)(`should have %s`, (element) => {
- expect(findItem(element).exists()).toBe(true);
- });
- }
+ if (shouldExist.length) {
+ it.each(shouldExist)(`should have %s`, (element) => {
+ expect(findItem(element).exists()).toBe(true);
+ });
+ }
- if (shouldNotExist.length) {
- it.each(shouldNotExist)(`should not have %s`, (element) => {
- expect(findItem(element).exists()).toBe(false);
+ if (shouldNotExist.length) {
+ it.each(shouldNotExist)(`should not have %s`, (element) => {
+ expect(findItem(element).exists()).toBe(false);
+ });
+ }
+
+ if (shouldExist.includes(LEAF_LINK)) {
+ it('the last link should be the last piece of the path', () => {
+ const leaf = findItem(LEAF_LINK);
+ expect(leaf.attributes('href')).toBe(`/${path}`);
+ expect(leaf.text()).toBe(pathPieces[pathPieces.length - 1]);
+ });
+ }
+ });
+
+ describe('disabled component', () => {
+ beforeEach(() => {
+ mountComponent({ path, disabled: true });
});
- }
- if (shouldExist.includes(LEAF_LINK)) {
- it('the last link should be the last piece of the path', () => {
- const leaf = findItem(LEAF_LINK);
- expect(leaf.attributes('href')).toBe(`/${path}`);
- expect(leaf.text()).toBe(pathPieces[pathPieces.length - 1]);
+ it('root link is disabled', () => {
+ expect(findItem(ROOT_LINK).attributes('disabled')).toBe('true');
});
- }
+
+ if (shouldExist.includes(LEAF_LINK)) {
+ it('the last link is disabled', () => {
+ expect(findItem(LEAF_LINK).attributes('disabled')).toBe('true');
+ });
+ }
+ });
});
});