mockaton 5.0.0 → 5.0.2

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "5.0.0",
5
+ "version": "5.0.2",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/Dashboard.js CHANGED
@@ -94,7 +94,6 @@ function CookieSelector({ list }) {
94
94
  method: 'PATCH',
95
95
  body: JSON.stringify(this.value)
96
96
  })
97
- .then(init)
98
97
  .catch(console.error)
99
98
  }
100
99
  }, list.map(([key, selected]) =>
@@ -132,8 +131,7 @@ function SectionByMethod({ method, brokers }) {
132
131
  r('tbody', null,
133
132
  r('th', null, method),
134
133
  Object.entries(brokers)
135
- .sort((a, b) => a[0].localeCompare(b[0]))
136
- .filter(([, broker]) => broker.mocks.length) // handles Markdown doc
134
+ .filter(([, broker]) => broker.mocks.length > 1) // Excludes Markdown only routes (>1 because of the autogen500)
137
135
  .map(([urlMask, broker]) =>
138
136
  r('tr', null,
139
137
  r('td', null, r(PreviewLink, { method, urlMask, documentation: broker.documentation })),
@@ -203,11 +201,13 @@ function MockSelector({ broker }) {
203
201
  fetch(API.edit, {
204
202
  method: 'PATCH',
205
203
  body: JSON.stringify({ [DF.file]: this.value })
206
- }).then(() => {
207
- this.closest('tr').querySelector('a').click()
208
- this.closest('tr').querySelector(`.${CSS.InternalServerErrorToggler}>[type=checkbox]`).checked = status === 500
209
- this.className = className(this.value === this.options[0].value, status)
210
204
  })
205
+ .then(() => {
206
+ this.closest('tr').querySelector('a').click()
207
+ this.closest('tr').querySelector(`.${CSS.InternalServerErrorToggler}>[type=checkbox]`).checked = status === 500
208
+ this.className = className(this.value === this.options[0].value, status)
209
+ })
210
+ .catch(console.error)
211
211
  }
212
212
  }, files.map(file => r('option', {
213
213
  value: file,
@@ -269,7 +269,9 @@ function InternalServerErrorToggler({ broker }) {
269
269
  ? items.find(f => Route.parseFilename(f).status === 500)
270
270
  : items[0]
271
271
  })
272
- }).then(init)
272
+ })
273
+ .then(init)
274
+ .catch(console.error)
273
275
  }
274
276
  }),
275
277
  r('span', null, '500')
package/src/MockBroker.js CHANGED
@@ -78,7 +78,7 @@ export class MockBroker {
78
78
  }
79
79
 
80
80
  #registerTemp500() {
81
- const { urlMask, method } = Route.parseFilename(this.mocks[0])
81
+ const { urlMask, method } = Route.parseFilename(this.mocks[0] || this.documentation)
82
82
  let mask = urlMask
83
83
  const t = join(Config.mocksDir, urlMask)
84
84
  if (existsSync(t) && lstatSync(t).isDirectory())