Skip to content

Commit

Permalink
fix: fucking lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Mar 10, 2020
1 parent b50ea32 commit cdb72db
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 48 deletions.
2 changes: 1 addition & 1 deletion examples/v3/e2e/test/provider.spec.js
Expand Up @@ -22,7 +22,7 @@ describe("Pact Verification", () => {
console.log(
"Middleware invoked before provider API - injecting Authorization token"
)

req.headers["MY_SPECIAL_HEADER"] = "my special value"

// e.g. ADD Bearer token
Expand Down
4 changes: 3 additions & 1 deletion examples/v3/todo-consumer/provider.js
Expand Up @@ -8,7 +8,9 @@ server.use((req, res, next) => {

// Get all animals
server.get("/projects", (req, res) => {
res.send("<?xml version='1.0'?><ns1:projects id='1234' xmlns:ns1='http://some.namespace/and/more/stuff'><ns1:project id='1' name='Project 1' type='activity'><ns1:tasks><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/></ns1:tasks></ns1:project><ns1:project id='1' name='Project 1' type='activity'><ns1:tasks><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/></ns1:tasks></ns1:project></ns1:projects>")
res.send(
"<?xml version='1.0'?><ns1:projects id='1234' xmlns:ns1='http://some.namespace/and/more/stuff'><ns1:project id='1' name='Project 1' type='activity'><ns1:tasks><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/></ns1:tasks></ns1:project><ns1:project id='1' name='Project 1' type='activity'><ns1:tasks><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/><ns1:task done='true' id='1' name='Task 1'/></ns1:tasks></ns1:project></ns1:projects>"
)
})

module.exports = {
Expand Down
6 changes: 3 additions & 3 deletions examples/v3/todo-consumer/src/todo.js
@@ -1,7 +1,7 @@
const axios = require("axios")
const parser = require("xml2json")
const eyes = require("eyes")
const R = require('ramda')
const R = require("ramda")

let serverUrl = "http://localhost:2203"

Expand All @@ -18,8 +18,8 @@ module.exports = {
eyes.inspect(response.data)
if (format === "xml") {
const result = JSON.parse(parser.toJson(response.data))
console.dir(result, {depth: 10})
return R.path(['ns1:projects'], result)
console.dir(result, { depth: 10 })
return R.path(["ns1:projects"], result)
}
return response.data
})
Expand Down
40 changes: 24 additions & 16 deletions examples/v3/todo-consumer/test/consumer.spec.js
Expand Up @@ -103,13 +103,14 @@ describe("Pact V3", () => {
.willRespondWith({
status: 200,
headers: { "Content-Type": "application/xml" },
body: new XmlBuilder("1.0", "UTF-8", "ns1:projects").build(
el => {
el.setAttributes({
id: "1234",
"xmlns:ns1": "http://some.namespace/and/more/stuff"
})
el.eachLike("ns1:project", {
body: new XmlBuilder("1.0", "UTF-8", "ns1:projects").build(el => {
el.setAttributes({
id: "1234",
"xmlns:ns1": "http://some.namespace/and/more/stuff",
})
el.eachLike(
"ns1:project",
{
id: integer(1),
type: "activity",
name: string("Project 1"),
Expand All @@ -118,17 +119,24 @@ describe("Pact V3", () => {
// "yyyy-MM-dd'T'HH:mm:ss.SZ",
// "2016-02-11T09:46:56.023Z"
// ),
}, project => {
},
project => {
project.appendElement("ns1:tasks", {}, task => {
task.eachLike("ns1:task", {
id: integer(1),
name: string("Task 1"),
done: boolean(true),
}, null, { examples: 5 })
task.eachLike(
"ns1:task",
{
id: integer(1),
name: string("Task 1"),
done: boolean(true),
},
null,
{ examples: 5 }
)
})
}, { examples: 2 })
}
),
},
{ examples: 2 }
)
}),
// body: `<?xml version="1.0" encoding="UTF-8"?>
// <projects foo="bar">
// <project id="1" name="Project 1" due="2016-02-11T09:46:56.023Z">
Expand Down
11 changes: 8 additions & 3 deletions examples/v3/todo-consumer/test/provider.spec.js
@@ -1,4 +1,9 @@
const { PactV3, Matchers, XmlBuilder, VerifierV3 } = require("../../../../src/v3")
const {
PactV3,
Matchers,
XmlBuilder,
VerifierV3,
} = require("../../../../src/v3")
const chai = require("chai")
const chaiAsPromised = require("chai-as-promised")
chai.use(chaiAsPromised)
Expand All @@ -15,8 +20,8 @@ describe("Pact XML Verification", () => {
provider: "XML Service",
providerBaseUrl: "http://localhost:8081",
pactUrls: [
"/Users/matthewfellows/development/public/pact-js/examples/v3/todo-consumer/pacts/TodoApp-TodoServiceV3.json"
]
"/Users/matthewfellows/development/public/pact-js/examples/v3/todo-consumer/pacts/TodoApp-TodoServiceV3.json",
],
// pactUrls: [
// path.resolve(
// process.cwd(),
Expand Down
30 changes: 18 additions & 12 deletions src/v3/native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/v3/xml/xmlBuilder.ts
Expand Up @@ -3,7 +3,11 @@ import { XmlElement } from "./xmlElement"
export class XmlBuilder {
private root: XmlElement

constructor(private version: string, private charset: string, rootElement: string) {
constructor(
private version: string,
private charset: string,
rootElement: string
) {
this.root = new XmlElement(rootElement)
}

Expand Down
27 changes: 19 additions & 8 deletions src/v3/xml/xmlElement.ts
Expand Up @@ -25,7 +25,11 @@ export class XmlElement extends XmlNode {
return this
}

public appendElement(name: string, attributes: XmlAttributes, cb?: Callback): XmlElement {
public appendElement(
name: string,
attributes: XmlAttributes,
cb?: Callback
): XmlElement {
const el = new XmlElement(name).setAttributes(attributes)
this.executeCallback(el, cb)
this.children.push(el)
Expand All @@ -39,11 +43,19 @@ export class XmlElement extends XmlNode {
return this
}


public eachLike(name: string, attributes: XmlAttributes, cb?: Callback, options: EachLikeOptions = {examples: 1}): XmlElement {
public eachLike(
name: string,
attributes: XmlAttributes,
cb?: Callback,
options: EachLikeOptions = { examples: 1 }
): XmlElement {
const el = new XmlElement(name).setAttributes(attributes)
this.executeCallback(el, cb)
this.children.push({ "pact:matcher:type": "type", value: el, examples: options.examples})
this.children.push({
"pact:matcher:type": "type",
value: el,
examples: options.examples,
})

return this
}
Expand All @@ -55,9 +67,8 @@ export class XmlElement extends XmlNode {
}
}


interface EachLikeOptions {
min?: number,
max?: number,
min?: number
max?: number
examples?: number
}
}
4 changes: 1 addition & 3 deletions src/v3/xml/xmlNode.ts
@@ -1,3 +1 @@
export class XmlNode {

}
export class XmlNode {}

0 comments on commit cdb72db

Please sign in to comment.