• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmcelhaney / counterfact / 5942933897

22 Aug 2023 06:59PM UTC coverage: 83.567% (-3.8%) from 87.388%
5942933897

push

github

web-flow
Merge pull request #517 from pmcelhaney/windows-support

disable the end-to-end test because it won't work on Windows

389 of 423 branches covered (91.96%)

Branch coverage included in aggregate %.

1818 of 2218 relevant lines covered (81.97%)

9.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.55
/src/typescript-generator/operation-coder.js
1
/* eslint-disable no-magic-numbers */
1✔
2
import nodePath from "node:path";
1✔
3

1✔
4
import { Coder } from "./coder.js";
1✔
5
import { OperationTypeCoder } from "./operation-type-coder.js";
1✔
6

1✔
7
export class OperationCoder extends Coder {
1✔
8
  requestMethod() {
1✔
9
    return this.requirement.url.split("/").at(-1).toUpperCase();
3✔
10
  }
3✔
11

1✔
12
  names() {
1✔
13
    return super.names(this.requestMethod());
1✔
14
  }
1✔
15

1✔
16
  write() {
1✔
17
    const responses = this.requirement.get("responses");
2✔
18

2✔
19
    const [firstStatusCode] = responses.map(
2✔
20
      (response, statusCode) => statusCode
2✔
21
    );
2✔
22
    const [firstResponse] = responses.map((response) => response.data);
2✔
23

2✔
24
    if (!("content" in firstResponse || "schema" in firstResponse)) {
2!
25
      return "() => { /* no response content specified in the OpenAPI document */ }";
×
26
    }
×
27

2✔
28
    return `($) => {
2✔
29
      return $.response[${
2✔
30
        firstStatusCode === "default" ? 200 : firstStatusCode
2✔
31
      }].random();
2✔
32
    }`;
2✔
33
  }
2✔
34

1✔
35
  typeDeclaration(namespace, script) {
1✔
36
    const operationTypeCoder = new OperationTypeCoder(this.requirement);
1✔
37

1✔
38
    return script.importType(operationTypeCoder);
1✔
39
  }
1✔
40

1✔
41
  modulePath() {
1✔
42
    const pathString = this.requirement.url
1✔
43
      .split("/")
1✔
44
      .at(-2)
1✔
45
      .replaceAll("~1", "/");
1✔
46

1✔
47
    return `${nodePath
1✔
48
      .join("path", pathString)
1✔
49
      .replaceAll("\\", "/")}.types.ts`;
1✔
50
  }
1✔
51
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc