browserstack-cypress-cli 1.6.0 → 1.8.1

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.
@@ -55,7 +55,7 @@ describe("zipUpload", () => {
55
55
  });
56
56
  });
57
57
 
58
- it("reject with error (if error present in response) if statusCode != 200", () => {
58
+ it("reject with error (if error present in response) if statusCode == 401", () => {
59
59
  let error = "non 200 code";
60
60
 
61
61
  let requestStub = sandbox
@@ -82,7 +82,7 @@ describe("zipUpload", () => {
82
82
  });
83
83
  });
84
84
 
85
- it("reject with message if statusCode != 200 and error not in response", () => {
85
+ it("reject with message if statusCode == 401 and error not in response", () => {
86
86
  let requestStub = sandbox
87
87
  .stub(request, "post")
88
88
  .yields(
@@ -98,6 +98,65 @@ describe("zipUpload", () => {
98
98
  request: { post: requestStub },
99
99
  });
100
100
 
101
+ return zipUploader
102
+ .zipUpload(bsConfig, "./random_file_path")
103
+ .then(function (data) {
104
+ chai.assert.fail("Promise error");
105
+ })
106
+ .catch((error) => {
107
+ sinon.assert.calledOnce(requestStub);
108
+ sinon.assert.calledOnce(getUserAgentStub);
109
+ sinon.assert.calledOnce(createReadStreamStub);
110
+ chai.assert.equal(
111
+ error,
112
+ Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS
113
+ );
114
+ });
115
+ });
116
+
117
+ it("reject with error (if error present in response) if statusCode != 200 and statusCode != 401", () => {
118
+ let error = "non 200 and non 401 code";
119
+
120
+ let requestStub = sandbox
121
+ .stub(request, "post")
122
+ .yields(null, { statusCode: 404 }, JSON.stringify({ error: error }));
123
+
124
+ const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
125
+ "./utils": {
126
+ getUserAgent: getUserAgentStub,
127
+ },
128
+ request: { post: requestStub },
129
+ });
130
+
131
+ return zipUploader
132
+ .zipUpload(bsConfig, "./random_file_path")
133
+ .then(function (data) {
134
+ chai.assert.fail("Promise error");
135
+ })
136
+ .catch((error) => {
137
+ sinon.assert.calledOnce(requestStub);
138
+ sinon.assert.calledOnce(getUserAgentStub);
139
+ sinon.assert.calledOnce(createReadStreamStub);
140
+ chai.assert.equal(error, "non 200 and non 401 code");
141
+ });
142
+ });
143
+
144
+ it("reject with message if statusCode != 200 and statusCode != 401 and error not in response", () => {
145
+ let requestStub = sandbox
146
+ .stub(request, "post")
147
+ .yields(
148
+ null,
149
+ { statusCode: 404 },
150
+ JSON.stringify({ message: "random message" })
151
+ );
152
+
153
+ const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
154
+ "./utils": {
155
+ getUserAgent: getUserAgentStub,
156
+ },
157
+ request: { post: requestStub },
158
+ });
159
+
101
160
  return zipUploader
102
161
  .zipUpload(bsConfig, "./random_file_path")
103
162
  .then(function (data) {