|
1 | 1 | /// <reference lib="dom" /> |
2 | 2 | import assert from 'node:assert/strict'; |
3 | | -import {test} from 'vitest'; |
| 3 | +import {test, expect} from 'vitest'; |
4 | 4 | import stripIndent from 'strip-indent'; |
5 | 5 | import {getAllUrls, getTests} from './collector.js'; |
6 | 6 | import * as pageDetect from './index.js'; |
@@ -153,48 +153,87 @@ test('getRepositoryInfo', () => { |
153 | 153 | assert.equal(getRepositoryInfoAdapter('https://github.com'), undefined); |
154 | 154 | assert.equal(getRepositoryInfoAdapter('https://gist.github.com/'), undefined); |
155 | 155 | assert.equal(getRepositoryInfoAdapter('https://github.com/settings/developers'), undefined); |
156 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection'), { |
157 | | - owner: 'refined-github', |
158 | | - name: 'github-url-detection', |
159 | | - nameWithOwner: 'refined-github/github-url-detection', |
160 | | - path: '', |
161 | | - }); |
162 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/'), { |
163 | | - owner: 'refined-github', |
164 | | - name: 'github-url-detection', |
165 | | - nameWithOwner: 'refined-github/github-url-detection', |
166 | | - path: '', |
167 | | - }); |
168 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/blame/master/package.json'), { |
169 | | - owner: 'refined-github', |
170 | | - name: 'github-url-detection', |
171 | | - nameWithOwner: 'refined-github/github-url-detection', |
172 | | - path: 'blame/master/package.json', |
173 | | - }); |
174 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/commit/57bf4'), { |
175 | | - owner: 'refined-github', |
176 | | - name: 'github-url-detection', |
177 | | - nameWithOwner: 'refined-github/github-url-detection', |
178 | | - path: 'commit/57bf4', |
179 | | - }); |
180 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/compare/test-branch?quick_pull=0'), { |
181 | | - owner: 'refined-github', |
182 | | - name: 'github-url-detection', |
183 | | - nameWithOwner: 'refined-github/github-url-detection', |
184 | | - path: 'compare/test-branch', |
185 | | - }); |
186 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/tree/master/distribution'), { |
187 | | - owner: 'refined-github', |
188 | | - name: 'github-url-detection', |
189 | | - nameWithOwner: 'refined-github/github-url-detection', |
190 | | - path: 'tree/master/distribution', |
191 | | - }); |
192 | | - assert.deepEqual(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/tree/master/distribution/'), { |
193 | | - owner: 'refined-github', |
194 | | - name: 'github-url-detection', |
195 | | - nameWithOwner: 'refined-github/github-url-detection', |
196 | | - path: 'tree/master/distribution', |
197 | | - }); |
| 156 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection')).toMatchInlineSnapshot(` |
| 157 | + { |
| 158 | + "name": "github-url-detection", |
| 159 | + "nameWithOwner": "refined-github/github-url-detection", |
| 160 | + "owner": "refined-github", |
| 161 | + "path": "", |
| 162 | + "pathParts": [], |
| 163 | + } |
| 164 | + `); |
| 165 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/')).toMatchInlineSnapshot(` |
| 166 | + { |
| 167 | + "name": "github-url-detection", |
| 168 | + "nameWithOwner": "refined-github/github-url-detection", |
| 169 | + "owner": "refined-github", |
| 170 | + "path": "", |
| 171 | + "pathParts": [], |
| 172 | + } |
| 173 | + `); |
| 174 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/blame/master/package.json')).toMatchInlineSnapshot(` |
| 175 | + { |
| 176 | + "name": "github-url-detection", |
| 177 | + "nameWithOwner": "refined-github/github-url-detection", |
| 178 | + "owner": "refined-github", |
| 179 | + "path": "blame/master/package.json", |
| 180 | + "pathParts": [ |
| 181 | + "blame", |
| 182 | + "master", |
| 183 | + "package.json", |
| 184 | + ], |
| 185 | + } |
| 186 | + `); |
| 187 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/commit/57bf4')).toMatchInlineSnapshot(` |
| 188 | + { |
| 189 | + "name": "github-url-detection", |
| 190 | + "nameWithOwner": "refined-github/github-url-detection", |
| 191 | + "owner": "refined-github", |
| 192 | + "path": "commit/57bf4", |
| 193 | + "pathParts": [ |
| 194 | + "commit", |
| 195 | + "57bf4", |
| 196 | + ], |
| 197 | + } |
| 198 | + `); |
| 199 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/compare/test-branch?quick_pull=0')).toMatchInlineSnapshot(` |
| 200 | + { |
| 201 | + "name": "github-url-detection", |
| 202 | + "nameWithOwner": "refined-github/github-url-detection", |
| 203 | + "owner": "refined-github", |
| 204 | + "path": "compare/test-branch", |
| 205 | + "pathParts": [ |
| 206 | + "compare", |
| 207 | + "test-branch", |
| 208 | + ], |
| 209 | + } |
| 210 | + `); |
| 211 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/tree/master/distribution')).toMatchInlineSnapshot(` |
| 212 | + { |
| 213 | + "name": "github-url-detection", |
| 214 | + "nameWithOwner": "refined-github/github-url-detection", |
| 215 | + "owner": "refined-github", |
| 216 | + "path": "tree/master/distribution", |
| 217 | + "pathParts": [ |
| 218 | + "tree", |
| 219 | + "master", |
| 220 | + "distribution", |
| 221 | + ], |
| 222 | + } |
| 223 | + `); |
| 224 | + expect(getRepositoryInfoAdapter('https://github.com/refined-github/github-url-detection/tree/master/distribution/')).toMatchInlineSnapshot(` |
| 225 | + { |
| 226 | + "name": "github-url-detection", |
| 227 | + "nameWithOwner": "refined-github/github-url-detection", |
| 228 | + "owner": "refined-github", |
| 229 | + "path": "tree/master/distribution", |
| 230 | + "pathParts": [ |
| 231 | + "tree", |
| 232 | + "master", |
| 233 | + "distribution", |
| 234 | + ], |
| 235 | + } |
| 236 | + `); |
198 | 237 | } |
199 | 238 | }); |
200 | 239 |
|
|
0 commit comments