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

Zaptyp / spotify-web-api-node / 16039825477

03 Jul 2025 01:59AM CUT coverage: 95.264%. Remained the same
16039825477

Pull #31

travis-ci

web-flow
Bump jest from 30.0.0 to 30.0.4

Bumps [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest) from 30.0.0 to 30.0.4.
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.0.4/packages/jest)

---
updated-dependencies:
- dependency-name: jest
  dependency-version: 30.0.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #31: Bump jest from 30.0.0 to 30.0.4

170 of 185 branches covered (91.89%)

Branch coverage included in aggregate %.

353 of 364 relevant lines covered (96.98%)

70.25 hits per line

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

95.59
/src/base-request.js
1
'use strict';
2

3
var Request = function (builder) {
10✔
4
  if (!builder) {
308!
5
    throw new Error('No builder supplied to constructor');
×
6
  }
7

8
  this.host = builder.host;
308✔
9
  this.port = builder.port;
308✔
10
  this.scheme = builder.scheme;
308✔
11
  this.queryParameters = builder.queryParameters;
308✔
12
  this.bodyParameters = builder.bodyParameters;
308✔
13
  this.headers = builder.headers;
308✔
14
  this.path = builder.path;
308✔
15
  this.timeout = builder.timeout;
308✔
16
};
17

18
Request.prototype._getter = function (key) {
10✔
19
  return function () {
80✔
20
    return this[key];
2,062✔
21
  };
22
};
23

24
Request.prototype.getHost = Request.prototype._getter('host');
10✔
25

26
Request.prototype.getPort = Request.prototype._getter('port');
10✔
27

28
Request.prototype.getScheme = Request.prototype._getter('scheme');
10✔
29

30
Request.prototype.getPath = Request.prototype._getter('path');
10✔
31

32
Request.prototype.getQueryParameters = Request.prototype._getter(
10✔
33
  'queryParameters'
34
);
35

36
Request.prototype.getBodyParameters = Request.prototype._getter(
10✔
37
  'bodyParameters'
38
);
39

40
Request.prototype.getHeaders = Request.prototype._getter('headers');
10✔
41

42
Request.prototype.getTimeout = Request.prototype._getter('timeout');
10✔
43

44
Request.prototype.getURI = function () {
10✔
45
  if (!this.scheme || !this.host || !this.port) {
296!
46
    throw new Error('Missing components necessary to construct URI');
×
47
  }
48
  var uri = this.scheme + '://' + this.host;
296✔
49
  if (
296✔
50
    (this.scheme === 'http' && this.port !== 80) ||
432✔
51
    (this.scheme === 'https' && this.port !== 443)
52
  ) {
53
    uri += ':' + this.port;
26✔
54
  }
55
  if (this.path) {
296✔
56
    uri += this.path;
272✔
57
  }
58
  return uri;
296✔
59
};
60

61
Request.prototype.getURL = function () {
10✔
62
  var uri = this.getURI();
6✔
63
  if (this.getQueryParameters()) {
6!
64
    return uri + this.getQueryParameterString(this.getQueryParameters());
6✔
65
  } else {
66
    return uri;
×
67
  }
68
};
69

70
Request.prototype.getQueryParameterString = function () {
10✔
71
  var queryParameters = this.getQueryParameters();
14✔
72
  if (queryParameters) {
14✔
73
    return (
12✔
74
      '?' +
75
      Object.keys(queryParameters)
76
        .filter(function (key) {
77
          return queryParameters[key] !== undefined;
50✔
78
        })
79
        .map(function (key) {
80
          return key + '=' + queryParameters[key];
46✔
81
        })
82
        .join('&')
83
    );
84
  }
85
};
86

87
Request.prototype.execute = function (method, callback) {
10✔
88
  if (callback) {
264✔
89
    method(this, callback);
68✔
90
    return;
68✔
91
  }
92
  var _self = this;
196✔
93

94
  return new Promise(function (resolve, reject) {
196✔
95
    method(_self, function (error, result) {
196✔
96
      if (error) {
196✔
97
        reject(error);
2✔
98
      } else {
99
        resolve(result);
194✔
100
      }
101
    });
102
  });
103
};
104

105
var Builder = function () {};
10✔
106

107
Builder.prototype._setter = function (key) {
10✔
108
  return function (value) {
50✔
109
    this[key] = value;
1,178✔
110
    return this;
1,178✔
111
  };
112
};
113

114
Builder.prototype.withHost = Builder.prototype._setter('host');
10✔
115

116
Builder.prototype.withPort = Builder.prototype._setter('port');
10✔
117

118
Builder.prototype.withScheme = Builder.prototype._setter('scheme');
10✔
119

120
Builder.prototype.withPath = Builder.prototype._setter('path');
10✔
121

122
Builder.prototype._assigner = function (key) {
10✔
123
  return function () {
30✔
124
    for (var i = 0; i < arguments.length; i++) {
492✔
125
      this[key] = this._assign(this[key], arguments[i]);
542✔
126
    }
127

128
    return this;
492✔
129
  };
130
};
131

132
Builder.prototype.withQueryParameters = Builder.prototype._assigner(
10✔
133
  'queryParameters'
134
);
135

136
Builder.prototype.withBodyParameters = Builder.prototype._assigner(
10✔
137
  'bodyParameters'
138
);
139

140
Builder.prototype.withHeaders = Builder.prototype._assigner('headers');
10✔
141

142
Builder.prototype.withTimeout = Builder.prototype._setter('timeout');
10✔
143

144
Builder.prototype.withAuth = function (accessToken) {
10✔
145
  if (accessToken) {
260✔
146
    this.withHeaders({ Authorization: 'Bearer ' + accessToken });
156✔
147
  }
148
  return this;
260✔
149
};
150

151
Builder.prototype._assign = function (src, obj) {
10✔
152
  if (obj && Array.isArray(obj)) {
542✔
153
    return obj;
8✔
154
  }
155
  if (obj && typeof obj === 'string') {
534✔
156
    return obj;
2✔
157
  }
158
  if (obj && Object.keys(obj).length > 0) {
532✔
159
    return Object.assign(src || {}, obj);
484✔
160
  }
161
  return src;
48✔
162
};
163

164
Builder.prototype.build = function () {
10✔
165
  return new Request(this);
308✔
166
};
167

168
module.exports.builder = function () {
10✔
169
  return new Builder();
308✔
170
};
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

© 2025 Coveralls, Inc