-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(formatting): Use shared prettier config
- Loading branch information
1 parent
872bb98
commit c74c6cd
Showing
135 changed files
with
5,461 additions
and
5,428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
trailingComma: "es5" | ||
semi: false | ||
'@pact-foundation/pact-js-prettier-config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
"use strict" | ||
'use strict'; | ||
|
||
const axios = require("axios") | ||
const axios = require('axios'); | ||
|
||
exports.getMeDogs = (endpoint) => { | ||
const url = endpoint.url | ||
const port = endpoint.port | ||
const url = endpoint.url; | ||
const port = endpoint.port; | ||
|
||
return axios.request({ | ||
method: "GET", | ||
method: 'GET', | ||
baseURL: `${url}:${port}`, | ||
url: "/dogs", | ||
url: '/dogs', | ||
headers: { | ||
Accept: "application/json", | ||
Accept: 'application/json', | ||
}, | ||
}) | ||
} | ||
}); | ||
}; | ||
|
||
exports.getMeDog = (endpoint) => { | ||
const url = endpoint.url | ||
const port = endpoint.port | ||
const url = endpoint.url; | ||
const port = endpoint.port; | ||
|
||
return axios.request({ | ||
method: "GET", | ||
method: 'GET', | ||
baseURL: `${url}:${port}`, | ||
url: "/dogs/1", | ||
url: '/dogs/1', | ||
headers: { | ||
Accept: "application/json", | ||
Accept: 'application/json', | ||
}, | ||
}) | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
"use strict" | ||
'use strict'; | ||
|
||
const path = require("path") | ||
const test = require("ava") | ||
const pact = require("@pact-foundation/pact") | ||
const Pact = pact.Pact | ||
const getMeDog = require("../index").getMeDog | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const pact = require('@pact-foundation/pact'); | ||
const Pact = pact.Pact; | ||
const getMeDog = require('../index').getMeDog; | ||
|
||
const url = "http://localhost" | ||
const port = 8990 | ||
const url = 'http://localhost'; | ||
const port = 8990; | ||
|
||
const provider = new Pact({ | ||
port: port, | ||
log: path.resolve(process.cwd(), "logs", "mockserver-integration.log"), | ||
dir: path.resolve(process.cwd(), "pacts"), | ||
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), | ||
dir: path.resolve(process.cwd(), 'pacts'), | ||
spec: 2, | ||
consumer: "Ava Consumer Example", | ||
provider: "Ava Provider Example", | ||
pactfileWriteMode: "merge", | ||
}) | ||
consumer: 'Ava Consumer Example', | ||
provider: 'Ava Provider Example', | ||
pactfileWriteMode: 'merge', | ||
}); | ||
|
||
test.before("setting up Dog API expectations", async () => { | ||
await provider.setup() | ||
}) | ||
test.before('setting up Dog API expectations', async () => { | ||
await provider.setup(); | ||
}); | ||
|
||
test("Dog API GET /dogs/1", async (t) => { | ||
t.plan(1) | ||
test('Dog API GET /dogs/1', async (t) => { | ||
t.plan(1); | ||
|
||
// BEGIN - | ||
// Setup interactions for expected API response from provider | ||
// This is done due to similar reasons of tear-up/down of database | ||
// data in tests. | ||
const interaction = { | ||
state: "dog 1 exists", | ||
uponReceiving: "a request for dog 1", | ||
state: 'dog 1 exists', | ||
uponReceiving: 'a request for dog 1', | ||
withRequest: { | ||
method: "GET", | ||
path: "/dogs/1", | ||
method: 'GET', | ||
path: '/dogs/1', | ||
headers: { | ||
Accept: "application/json", | ||
Accept: 'application/json', | ||
}, | ||
}, | ||
willRespondWith: { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "application/json", | ||
'Content-Type': 'application/json', | ||
}, | ||
body: [ | ||
{ | ||
dog: pact.Matchers.somethingLike(1), | ||
name: pact.Matchers.term({ | ||
matcher: "(\\S+)", | ||
generate: "rocky", | ||
matcher: '(\\S+)', | ||
generate: 'rocky', | ||
}), | ||
}, | ||
], | ||
}, | ||
} | ||
}; | ||
|
||
await provider.addInteraction(interaction) | ||
await provider.addInteraction(interaction); | ||
// END | ||
|
||
const urlAndPort = { | ||
url: url, | ||
port: port, | ||
} | ||
const response = await getMeDog(urlAndPort) | ||
}; | ||
const response = await getMeDog(urlAndPort); | ||
t.deepEqual(response.data, [ | ||
{ | ||
dog: 1, | ||
name: "rocky", | ||
name: 'rocky', | ||
}, | ||
]) | ||
]); | ||
|
||
// verify with Pact, and reset expectations | ||
await provider.verify() | ||
}) | ||
await provider.verify(); | ||
}); | ||
|
||
test.after.always("pact.js mock server graceful shutdown", async () => { | ||
await provider.finalize() | ||
}) | ||
test.after.always('pact.js mock server graceful shutdown', async () => { | ||
await provider.finalize(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
"use strict" | ||
'use strict'; | ||
|
||
const path = require("path") | ||
const test = require("ava") | ||
const pact = require("@pact-foundation/pact") | ||
const Pact = pact.Pact | ||
const getMeDogs = require("../index").getMeDogs | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const pact = require('@pact-foundation/pact'); | ||
const Pact = pact.Pact; | ||
const getMeDogs = require('../index').getMeDogs; | ||
|
||
const url = "http://localhost" | ||
const port = 8989 | ||
const url = 'http://localhost'; | ||
const port = 8989; | ||
|
||
const provider = new Pact({ | ||
port: port, | ||
log: path.resolve(process.cwd(), "logs", "mockserver-integration.log"), | ||
dir: path.resolve(process.cwd(), "pacts"), | ||
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), | ||
dir: path.resolve(process.cwd(), 'pacts'), | ||
spec: 2, | ||
consumer: "Ava Consumer Example", | ||
provider: "Ava Provider Example", | ||
pactfileWriteMode: "merge", | ||
}) | ||
consumer: 'Ava Consumer Example', | ||
provider: 'Ava Provider Example', | ||
pactfileWriteMode: 'merge', | ||
}); | ||
|
||
test.before("setting up Dog API expectations", async () => { | ||
await provider.setup() | ||
}) | ||
test.before('setting up Dog API expectations', async () => { | ||
await provider.setup(); | ||
}); | ||
|
||
test("Dog API GET /dogs", async (t) => { | ||
t.plan(1) | ||
test('Dog API GET /dogs', async (t) => { | ||
t.plan(1); | ||
|
||
// BEGIN - | ||
// Setup interactions for expected API response from provider | ||
// This is done due to similar reasons of tear-up/down of database | ||
// data in tests. | ||
const interaction = { | ||
state: "i have a list of dogs", | ||
uponReceiving: "a request for all dogs", | ||
state: 'i have a list of dogs', | ||
uponReceiving: 'a request for all dogs', | ||
withRequest: { | ||
method: "GET", | ||
path: "/dogs", | ||
method: 'GET', | ||
path: '/dogs', | ||
headers: { | ||
Accept: "application/json", | ||
Accept: 'application/json', | ||
}, | ||
}, | ||
willRespondWith: { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "application/json", | ||
'Content-Type': 'application/json', | ||
}, | ||
body: [ | ||
{ | ||
dog: pact.Matchers.somethingLike(1), | ||
name: pact.Matchers.term({ | ||
matcher: "(\\S+)", | ||
generate: "rocky", | ||
matcher: '(\\S+)', | ||
generate: 'rocky', | ||
}), | ||
}, | ||
], | ||
}, | ||
} | ||
}; | ||
|
||
await provider.addInteraction(interaction) | ||
await provider.addInteraction(interaction); | ||
// END | ||
|
||
const urlAndPort = { | ||
url: url, | ||
port: port, | ||
} | ||
const response = await getMeDogs(urlAndPort) | ||
}; | ||
const response = await getMeDogs(urlAndPort); | ||
t.deepEqual(response.data, [ | ||
{ | ||
dog: 1, | ||
name: "rocky", | ||
name: 'rocky', | ||
}, | ||
]) | ||
]); | ||
|
||
// verify with Pact, and reset expectations | ||
await provider.verify() | ||
}) | ||
await provider.verify(); | ||
}); | ||
|
||
test.after.always("pact.js mock server graceful shutdown", async () => { | ||
await provider.finalize() | ||
}) | ||
test.after.always('pact.js mock server graceful shutdown', async () => { | ||
await provider.finalize(); | ||
}); |
Oops, something went wrong.