-
Notifications
You must be signed in to change notification settings - Fork 1
/
rules.test.js
40 lines (36 loc) · 1.51 KB
/
rules.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as rules from "./rules.js"
const TOKEN = "example-token"
const SERVER = "example.com"
describe("run", () => {
it("works with just a token", () => {
const conf = rules.make(TOKEN)
expect(conf).toEqual({
auth_rule: `url.https://${TOKEN}:[email protected]/.insteadof`,
auth_url: `https://${TOKEN}:[email protected]/`,
https_url: "https://github.com/",
section: `url.https://${TOKEN}:[email protected]/`,
ssh_url: "[email protected]:",
})
})
it("works with token and server", () => {
const conf = rules.make(TOKEN, SERVER)
expect(conf).toEqual({
auth_rule: `url.https://${TOKEN}:x-oauth-basic@${SERVER}/.insteadof`,
auth_url: `https://${TOKEN}:x-oauth-basic@${SERVER}/`,
https_url: `https://${SERVER}/`,
section: `url.https://${TOKEN}:x-oauth-basic@${SERVER}/`,
ssh_url: `git@${SERVER}:`,
})
})
it("works with token and server and a prefix", () => {
const PREFIX = "org"
const conf = rules.make(TOKEN, SERVER, PREFIX)
expect(conf).toEqual({
auth_rule: `url.https://${TOKEN}:x-oauth-basic@${SERVER}/${PREFIX}.insteadof`,
auth_url: `https://${TOKEN}:x-oauth-basic@${SERVER}/${PREFIX}`,
https_url: `https://${SERVER}/${PREFIX}`,
section: `url.https://${TOKEN}:x-oauth-basic@${SERVER}/${PREFIX}`,
ssh_url: `git@${SERVER}:${PREFIX}`,
})
})
})