@tryghost/express-test 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ const {makeMessageFromMatchMessage} = require('./utils');
8
8
  * @prop {function} fn - Wrapped assertion with response context
9
9
  * @prop {string} [message] - The message to display if the assertion fails
10
10
  * @prop {string} [method] - The method to call on the assertion object
11
- * @prop {'header' | 'status'} [type] - The type of assertion
11
+ * @prop {'body' | 'header' | 'status'} type - The type of assertion, with following priority: body > header > status
12
12
  * @prop {import('assert').AssertionError} [error] - The error to throw if the assertion fails
13
13
  * @prop {any} [expected]
14
14
  * @prop {any} [expectedValue]
@@ -43,7 +43,8 @@ class ExpectRequest extends Request {
43
43
  };
44
44
 
45
45
  const assertion = {
46
- fn: wrapperFn
46
+ fn: wrapperFn,
47
+ type: 'body'
47
48
  };
48
49
 
49
50
  this._addAssertion(assertion);
@@ -80,7 +81,8 @@ class ExpectRequest extends Request {
80
81
  let assertion = {
81
82
  fn: this._assertSnapshot,
82
83
  properties: properties,
83
- field: 'body'
84
+ field: 'body',
85
+ type: 'body'
84
86
  };
85
87
 
86
88
  this._addAssertion(assertion);
@@ -139,12 +141,14 @@ class ExpectRequest extends Request {
139
141
  const headerAssertions = [];
140
142
 
141
143
  for (const assertion of this.assertions) {
142
- if (!['status', 'header'].includes(assertion.type)) {
144
+ if (assertion.type === 'body') {
143
145
  assertion.fn(response, assertion);
144
146
  } else if (assertion.type === 'status') {
145
147
  statusCodeAssertions.push(assertion);
146
148
  } else if (assertion.type === 'header') {
147
149
  headerAssertions.push(assertion);
150
+ } else {
151
+ headerAssertions.push(assertion);
148
152
  }
149
153
  }
150
154
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/express-test",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/express-test",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -26,9 +26,9 @@
26
26
  "sinon": "13.0.1"
27
27
  },
28
28
  "dependencies": {
29
- "@tryghost/jest-snapshot": "^0.3.3",
29
+ "@tryghost/jest-snapshot": "^0.3.4",
30
30
  "cookiejar": "^2.1.3",
31
31
  "reqresnext": "^1.7.0"
32
32
  },
33
- "gitHead": "64606b3f53d3ec8e6bf988f694d9dc4bbf5fac70"
33
+ "gitHead": "3768b2b29fe5c2ae4e535264246bc78933eba372"
34
34
  }