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

FeatureProbe / client-sdk-js / 3710670820

pending completion
3710670820

Pull #6

github

GitHub
Merge b47e6651e into d544ced96
Pull Request #6: version: 1.2.0

57 of 68 branches covered (83.82%)

Branch coverage included in aggregate %.

38 of 38 new or added lines in 3 files covered. (100.0%)

207 of 226 relevant lines covered (91.59%)

6.72 hits per line

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

75.76
/src/platform.ts
1
import "whatwg-fetch";
2✔
2
import { IHttpRequest, IPlatForm } from "./types";
3
import StorageProvider from "./localStorage";
2✔
4
import pkg from '../package.json';
2✔
5

6
const PKG_VERSION = pkg.version;
2✔
7
const UA = "JS/" + PKG_VERSION;
2✔
8

9
const httpRequest:IHttpRequest = {
2✔
10
  get: function(url, headers, data, successCb, errorCb) {
11
    fetch(url.toString() + '?' + new URLSearchParams(data), {
20✔
12
      method: "GET",
13
      cache: "no-cache",
14
      headers: headers,
15
    })
16
    .then(response => {
17
      if (response.status >= 200 && response.status < 300) {
10!
18
        return response;
10✔
19
      } else {
20
        const error: Error = new Error(response.statusText);
×
21
        throw error;
×
22
      }
23
    })
24
    .then(response => response.json())
10✔
25
    .then(json => {
26
      successCb(json);
10✔
27
    })
28
    .catch(e => {
29
      errorCb(e);
10✔
30
    });
31
  },
32
  post: function(url, headers, data, successCb, errorCb) {
33
    fetch(url.toString(), {
18✔
34
      method: "POST",
35
      cache: "no-cache",
36
      headers: headers,
37
      body: data,
38
    })
39
    .then(response => {
40
      if (response.status >= 200 && response.status < 300) {
18!
41
        return response;
18✔
42
      } else {
43
        const error: Error = new Error(response.statusText);
×
44
        throw error;
×
45
      }
46
    })
47
    // .then(response => response.json())
48
    .then(() => {
49
      successCb();
18✔
50
    })
51
    .catch(e => {
52
      errorCb(e);
×
53
    });
54
  }
55
};
56

57
const Platform = {
2✔
58
  default: {
59
    UA: UA,
60
    localStorage: new StorageProvider(),
61
    httpRequest: httpRequest,
62
  }
63
}
64

65
function setPlatform(platform: IPlatForm) {
66
  Platform.default = platform;
×
67
}
68

69
function getPlatform() {
70
  return Platform.default;
90✔
71
}
72

73
export { getPlatform, setPlatform };
2✔
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