counterfact 0.3.0 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # counterfact
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ab38cb2: add a tools.randomFromSchema(schema: JSONSchema) function
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterfact",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "a library for building a fake REST API for testing",
5
5
  "type": "module",
6
6
  "main": "./src/counterfact.js",
@@ -34,14 +34,15 @@
34
34
  "eslint": "8.18.0",
35
35
  "eslint-config-hardcore": "24.5.0",
36
36
  "eslint-formatter-github-annotations": "0.1.0",
37
+ "husky": "8.0.1",
37
38
  "jest": "28.1.2",
38
39
  "koa": "2.13.4",
39
- "husky": "8.0.1",
40
40
  "nodemon": "2.0.18",
41
41
  "stryker-cli": "1.0.2",
42
42
  "supertest": "6.2.3"
43
43
  },
44
44
  "dependencies": {
45
- "chokidar": "^3.5.3"
45
+ "chokidar": "^3.5.3",
46
+ "json-schema-faker": "^0.5.0-rcv.44"
46
47
  }
47
48
  }
package/src/tools.js CHANGED
@@ -1,3 +1,5 @@
1
+ import JSONSchemaFaker from "json-schema-faker";
2
+
1
3
  export class Tools {
2
4
  constructor({ headers = {} } = {}) {
3
5
  this.headers = headers;
@@ -25,4 +27,8 @@ export class Tools {
25
27
  );
26
28
  });
27
29
  }
30
+
31
+ randomFromSchema(schema) {
32
+ return JSONSchemaFaker.generate(schema);
33
+ }
28
34
  }
@@ -36,4 +36,10 @@ describe("tools", () => {
36
36
  expect(tools.accepts(contentType)).toBe(false);
37
37
  }
38
38
  );
39
+
40
+ it("randomFromSchema() returns a value (the implementation is in a third party library)", () => {
41
+ const tools = new Tools();
42
+
43
+ expect(typeof tools.randomFromSchema({ type: "integer" })).toBe("number");
44
+ });
39
45
  });