|
1 | | -import { getDbItemActions } from "../../../../src/databases/ui/db-tree-view-item-action"; |
| 1 | +import { |
| 2 | + getDbItemActions, |
| 3 | + getGitHubUrl, |
| 4 | +} from "../../../../src/databases/ui/db-tree-view-item-action"; |
2 | 5 | import { |
3 | 6 | createLocalDatabaseDbItem, |
4 | 7 | createLocalListDbItem, |
@@ -107,3 +110,51 @@ describe("getDbItemActions", () => { |
107 | 110 | expect(actions.includes("canBeSelected")).toBeFalsy(); |
108 | 111 | }); |
109 | 112 | }); |
| 113 | + |
| 114 | +describe("getGitHubUrl", () => { |
| 115 | + it("should return the correct url for a remote owner", () => { |
| 116 | + const dbItem = createRemoteOwnerDbItem(); |
| 117 | + |
| 118 | + const actualUrl = getGitHubUrl(dbItem); |
| 119 | + const expectedUrl = `https://github.com/${dbItem.ownerName}`; |
| 120 | + |
| 121 | + expect(actualUrl).toEqual(expectedUrl); |
| 122 | + }); |
| 123 | + |
| 124 | + it("should return the correct url for a remote repo", () => { |
| 125 | + const dbItem = createRemoteRepoDbItem(); |
| 126 | + |
| 127 | + const actualUrl = getGitHubUrl(dbItem); |
| 128 | + const expectedUrl = `https://github.com/${dbItem.repoFullName}`; |
| 129 | + |
| 130 | + expect(actualUrl).toEqual(expectedUrl); |
| 131 | + }); |
| 132 | + |
| 133 | + it("should return undefined for other remote db items", () => { |
| 134 | + const dbItem0 = createRootRemoteDbItem(); |
| 135 | + const dbItem1 = createRemoteSystemDefinedListDbItem(); |
| 136 | + const dbItem2 = createRemoteUserDefinedListDbItem(); |
| 137 | + |
| 138 | + const actualUrl0 = getGitHubUrl(dbItem0); |
| 139 | + const actualUrl1 = getGitHubUrl(dbItem1); |
| 140 | + const actualUrl2 = getGitHubUrl(dbItem2); |
| 141 | + |
| 142 | + expect(actualUrl0).toBeUndefined(); |
| 143 | + expect(actualUrl1).toBeUndefined(); |
| 144 | + expect(actualUrl2).toBeUndefined(); |
| 145 | + }); |
| 146 | + |
| 147 | + it("should return undefined for local db items", () => { |
| 148 | + const dbItem0 = createRootLocalDbItem(); |
| 149 | + const dbItem1 = createLocalDatabaseDbItem(); |
| 150 | + const dbItem2 = createLocalListDbItem(); |
| 151 | + |
| 152 | + const actualUrl0 = getGitHubUrl(dbItem0); |
| 153 | + const actualUrl1 = getGitHubUrl(dbItem1); |
| 154 | + const actualUrl2 = getGitHubUrl(dbItem2); |
| 155 | + |
| 156 | + expect(actualUrl0).toBeUndefined(); |
| 157 | + expect(actualUrl1).toBeUndefined(); |
| 158 | + expect(actualUrl2).toBeUndefined(); |
| 159 | + }); |
| 160 | +}); |
0 commit comments