Skip to content

Commit

Permalink
wip: convert main classes to crude TS implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Aug 20, 2017
1 parent c6e6c3a commit 084b6d3
Show file tree
Hide file tree
Showing 23 changed files with 759 additions and 514 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

# Matches multiple files with brace expansion notation
# Set default charset
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ For simplicity, we alias the main matches to make our code more readable:
The underlying mock service is written in Ruby, so the regular expression must be in a Ruby format, not a Javascript format.

```javascript
const { term } = pact.Matchers
const { term } = pact

provider.addInteraction({
state: 'Has some animals',
Expand Down Expand Up @@ -343,7 +343,7 @@ provider.addInteraction({
#### Match based on type

```javascript
const { somethingLike: like } = pact.Matchers
const { like } = pact

provider.addInteraction({
state: 'Has some animals',
Expand Down Expand Up @@ -379,15 +379,15 @@ Note that you can wrap a `like` around a single value or an object. When wrapped
Matching provides the ability to specify flexible length arrays. For example:

```javascript
pact.Matchers.eachLike(obj, { min: 3 })
pact.eachLike(obj, { min: 3 })
```

Where `obj` can be any javascript object, value or Pact.Match. It takes optional argument (`{ min: 3 }`) where min is greater than 0 and defaults to 1 if not provided.

Below is an example that uses all of the Pact Matchers.

```javascript
const { somethingLike: like, term, eachLike } = pact.Matchers
const { somethingLike: like, term, eachLike } = pact

const animalBodyExpectation = {
'id': 1,
Expand Down
166 changes: 166 additions & 0 deletions package-lock.json

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

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Pact for all things Javascript",
"main": "./src/pact.js",
"types": "./src/pact.d.ts",
"typings": "./src/types/custom.d.ts",
"scripts": {
"build": "./node_modules/.bin/tsc",
"clean": "rimraf docs dist dist-web coverage logs pacts jscpd.json",
Expand All @@ -16,7 +17,8 @@
"postdist": "npm t",
"posttest": "npm run test:checkCoverage && npm run test:karma && npm run docs",
"predist": "npm run clean && npm run lint && npm run jscpd",
"test": "istanbul cover ./node_modules/.bin/_mocha --timeout 10000 -- ./test",
"test": "istanbul cover ./node_modules/.bin/_mocha -- ./test/**/*.js",
"test:typescript": "istanbul cover ./node_modules/.bin/_mocha -- ./test/**/*.ts",
"test:checkCoverage": "istanbul check",
"test:e2e-examples": "cd examples/e2e && npm i && npm t",
"test:karma": "npm run test:karma:jasmine && npm run test:karma:mocha",
Expand Down Expand Up @@ -81,6 +83,13 @@
"lodash.omitby": "4.6.0"
},
"devDependencies": {
"@types/chai": "^4.0.3",
"@types/cli-color": "^0.3.29",
"@types/lodash": "^4.14.73",
"@types/lodash.isnil": "^4.0.3",
"@types/mocha": "^2.2.41",
"@types/proxyquire": "^1.3.27",
"@types/sinon": "^2.3.3",
"awesome-typescript-loader": "^3.2.3",
"babel-cli": "6.x",
"babel-eslint": "6.x",
Expand Down Expand Up @@ -112,6 +121,7 @@
"source-map-loader": "^0.2.1",
"standard": "8.x",
"superagent": "2.x",
"ts-node": "^3.3.0",
"tslint": "^5.6.0",
"typescript": "^2.4.2",
"webpack": "^3.5.5"
Expand Down
4 changes: 2 additions & 2 deletions src/common/request.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';

export class Request {
constructor ();
send (method: HTTPMethod, url: string, body: string): Promise<string>;
constructor();
send(method: HTTPMethod, url: string, body?: string): Promise<string>;
}
32 changes: 0 additions & 32 deletions src/dsl/interaction.d.ts

This file was deleted.

Loading

0 comments on commit 084b6d3

Please sign in to comment.