| 1 | import { describe, expect, it } from 'vitest'; |
| 2 | |
| 3 | import { grantableScopes, hasScope |
| 4 | |
| 5 | describe('hasScope', () |
| 6 | it('accepts a scope that is granted or implied by a broader one', |
| 7 | expect(hasScope(['repo |
| 8 | expect(hasScope(['repo |
| 9 | expect(hasScope(['admin:org |
| 10 | expect(hasScope(['admin:public_key |
| 11 | expect(hasScope(['user |
| 12 | }); |
| 13 | |
| 14 | it('refuses a broader scope than the one granted', |
| 15 | expect(hasScope(['public_repo |
| 16 | expect(hasScope(['read:org |
| 17 | expect(hasScope([], |
| 18 | }); |
| 19 | }); |
| 20 | |
| 21 | describe('grantableScopes', () |
| 22 | it('keeps the known scopes gh asks for and drops the rest', |
| 23 | expect(grantableScopes('repo read:org gist workflow codespace |
| 24 | expect(grantableScopes('')) |
| 25 | }); |
| 26 | }); |
| 27 | |
| 28 | describe('scopesOfKey', () |
| 29 | it('reads the scopes a key was granted', |
| 30 | expect(scopesOfKey({ |
| 31 | }); |
| 32 | |
| 33 | it('gives a key made in Ghost, which has no scopes, every scope', |
| 34 | expect(scopesOfKey(null)) |
| 35 | expect(scopesOfKey({})) |
| 36 | }); |
| 37 | }); |