nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: alecthomas/chroma
Pull request #421 (2020-11-06 20:47:01)

Rust multi-line strings
Quoting Rust documentation

> Line-breaks are allowed in string literals. A line-break is either a newline
> (U+000A) or a pair of carriage return and newline (U+000D, U+000A).

https://doc.rust-lang.org/reference/tokens.html#string-literals


Patch:
diff --git a/lexers/r/rust.go b/lexers/r/rust.go
index 959f11c..1d7c09d 100644
--- a/lexers/r/rust.go
+++ b/lexers/r/rust.go
@@ -28,8 +28,8 @@ var Rust = internal.Register(MustNewLexer(
 			{`/\*\*(\n|[^/*])`, LiteralStringDoc, Push("doccomment")},
 			{`/\*!`, LiteralStringDoc, Push("doccomment")},
 			{`/\*`, CommentMultiline, Push("comment")},
-			{`r#*"(?:\\.|[^\\\r\n;])*"#*`, LiteralString, nil},
-			{`"(?:\\.|[^\\\r\n"])*"`, LiteralString, nil},
+			{`r#*"(?:\\.|[^\\;])*"#*`, LiteralString, nil},
+			{`"(?:\\.|[^\\"])*"`, LiteralString, nil},
 			{`\$([a-zA-Z_]\w*|\(,?|\),?|,?)`, CommentPreproc, nil},
 			{Words(``, `\b`, `as`, `async`, `await`, `const`, `crate`, `else`, `extern`, `for`, `if`, `impl`, `in`, `loop`, `match`, `move`, `mut`, `pub`, `ref`, `return`, `static`, `super`, `trait`, `unsafe`, `use`, `where`, `while`), Keyword, nil},
 			{Words(``, `\b`, `abstract`, `become`, `box`, `do`, `final`, `macro`, `override`, `priv`, `try`, `typeof`, `unsized`, `virtual`, `yield`), KeywordReserved, nil},


Test patch:
diff --git a/lexers/testdata/rust.actual b/lexers/testdata/rust.actual
index bd878c0..093f15b 100644
--- a/lexers/testdata/rust.actual
+++ b/lexers/testdata/rust.actual
@@ -14,4 +14,10 @@ fn main() {
 
     let r#type = "valid";
     let i: i128 = 1117;
+
+    let s = "March
+April";
+    let s = r"March
+April";
+
 }
diff --git a/lexers/testdata/rust.expected b/lexers/testdata/rust.expected
index 4912752..ad833e7 100644
--- a/lexers/testdata/rust.expected
+++ b/lexers/testdata/rust.expected
@@ -86,7 +86,25 @@
   {"type":"TextWhitespace","value":" "},
   {"type":"LiteralNumberInteger","value":"1117"},
   {"type":"Punctuation","value":";"},
-  {"type":"TextWhitespace","value":"\n"},
+  {"type":"TextWhitespace","value":"\n\n    "},
+  {"type":"KeywordDeclaration","value":"let"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Name","value":"s"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"="},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralString","value":"\"March\nApril\""},
+  {"type":"Punctuation","value":";"},
+  {"type":"TextWhitespace","value":"\n    "},
+  {"type":"KeywordDeclaration","value":"let"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Name","value":"s"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"="},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralString","value":"r\"March\nApril\""},
+  {"type":"Punctuation","value":";"},
+  {"type":"TextWhitespace","value":"\n\n"},
   {"type":"Punctuation","value":"}"},
   {"type":"TextWhitespace","value":"\n"}
 ]
Repository: valyala/fasthttp
Pull request #1878 (2024-10-01 16:37:21)

feat (request): expose req timeout
# Summary

Implemented `GetRequestTimeout` func to get the timeout attribute of the request.


# Related Issue
#1745


pd: is this what you guys had in mind?. I still need to document this btw.

erikdubbelboer: Why as a string?
erikdubbelboer: I think just returning a `time.Duration` is good. The most important part is the description of the function, it should describe exactly what this is for.

Patch:
diff --git a/http.go b/http.go
index f821701..2a9a6cb 100644
--- a/http.go
+++ b/http.go
@@ -192,6 +192,16 @@ func (req *Request) SetConnectionClose() {
 	req.Header.SetConnectionClose()
 }
 
+// GetTimeOut retrieves the timeout duration set for the Request.
+//
+// This method returns a time.Duration that determines how long the request
+// can wait before it times out. In the default use case, the timeout applies
+// to the entire request lifecycle, including both receiving the response
+// headers and the response body.
+func (req *Request) GetTimeOut() time.Duration {
+	return req.timeout
+}
+
 // SendFile registers file on the given path to be used as response body
 // when Write is called.
 //


Test patch:
diff --git a/http_test.go b/http_test.go
index 86ceaae..8ec2462 100644
--- a/http_test.go
+++ b/http_test.go
@@ -3174,3 +3174,26 @@ func TestRespCopeToRace(t *testing.T) {
 		}
 	}
 }
+
+func TestRequestGetTimeOut(t *testing.T) {
+	tests := []struct {
+		name     string
+		timeout  time.Duration
+		expected time.Duration
+	}{
+		{"Timeout set to 0", 0, 0},
+		{"Timeout set to 5s", 5 * time.Second, 5 * time.Second},
+		{"Timeout set to 1m", 1 * time.Minute, 1 * time.Minute},
+		{"Timeout set to 500ms", 500 * time.Millisecond, 500 * time.Millisecond},
+	}
+
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			req := &Request{timeout: test.timeout}
+
+			if got := req.GetTimeOut(); got != test.expected {
+				t.Errorf("GetTimeOut() = %v, want %v", got, test.expected)
+			}
+		})
+	}
+}
Repository: valyala/fasthttp
Pull request #918 (2020-11-22 23:12:44)

Fixing deletion of headers/queryargs having multiple values.
In a HTTP Request Headers/QueryArgs can have multiple values for the same key. Currently [delAllArgs](https://github.com/valyala/fasthttp/blob/master/args.go#L387-L399) doesn't delete all the headers/queryargs with the same key. This change fixes it by setting the index `i` to be checked next for deletion, correctly.

I have extracted relevant parts of code in [playground](https://play.golang.org/p/JmE2-Y8vz2k) to show the before and after changes.


Patch:
diff --git a/args.go b/args.go
index b3ad7e0..d1e57cf 100644
--- a/args.go
+++ b/args.go
@@ -391,6 +391,7 @@ func delAllArgs(args []argsKV, key string) []argsKV {
 			tmp := *kv
 			copy(args[i:], args[i+1:])
 			n--
+			i--
 			args[n] = tmp
 			args = args[:n]
 		}


Test patch:
diff --git a/args_test.go b/args_test.go
index f6c62ae..b2e1954 100644
--- a/args_test.go
+++ b/args_test.go
@@ -583,3 +583,17 @@ func testArgsParse(t *testing.T, a *Args, s string, expectedLen int, expectedArg
 		}
 	}
 }
+
+func TestArgsDeleteAll(t *testing.T) {
+	t.Parallel()
+	var a Args
+	a.Add("q1", "foo")
+	a.Add("q1", "bar")
+	a.Add("q1", "baz")
+	a.Add("q1", "quux")
+	a.Add("q2", "1234")
+	a.Del("q1")
+	if a.Len() != 1 || a.Has("q1") {
+		t.Fatalf("Expected q1 arg to be completely deleted. Current Args: %s", a.String())
+	}
+}
\ No newline at end of file
Repository: valyala/fasthttp
Pull request #1218 (2022-02-16 03:52:34)

RequestHeader support set no default ContentType
#873

In the definition of restful style api, the deletion of resources is generally defined as follows: 

```go
delete /students/{student_id}
```

there is no need to pass in a body, so add a func SetNoDefaultContentType to RequestHeader.



Patch:
diff --git a/header.go b/header.go
index 123fe95..e74bbc3 100644
--- a/header.go
+++ b/header.go
@@ -59,9 +59,10 @@ type ResponseHeader struct {
 type RequestHeader struct {
 	noCopy noCopy //nolint:unused,structcheck
 
-	disableNormalizing bool
-	noHTTP11           bool
-	connectionClose    bool
+	disableNormalizing   bool
+	noHTTP11             bool
+	connectionClose      bool
+	noDefaultContentType bool
 
 	// These two fields have been moved close to other bool fields
 	// for reducing RequestHeader object size.
@@ -943,9 +944,15 @@ func (h *ResponseHeader) resetSkipNormalize() {
 	h.trailer = h.trailer[:0]
 }
 
+// SetNoDefaultContentType allows you to control if a default Content-Type header will be set (false) or not (true).
+func (h *RequestHeader) SetNoDefaultContentType(noDefaultContentType bool) {
+	h.noDefaultContentType = noDefaultContentType
+}
+
 // Reset clears request header.
 func (h *RequestHeader) Reset() {
 	h.disableNormalizing = false
+	h.SetNoDefaultContentType(false)
 	h.resetSkipNormalize()
 }
 
@@ -2273,7 +2280,7 @@ func (h *RequestHeader) AppendBytes(dst []byte) []byte {
 	}
 
 	contentType := h.ContentType()
-	if len(contentType) == 0 && !h.ignoreBody() {
+	if !h.noDefaultContentType && len(contentType) == 0 && !h.ignoreBody() {
 		contentType = strDefaultContentType
 	}
 	if len(contentType) > 0 {


Test patch:
diff --git a/header_test.go b/header_test.go
index f041577..e313f49 100644
--- a/header_test.go
+++ b/header_test.go
@@ -1381,6 +1381,33 @@ func TestRequestContentTypeDefaultNotEmpty(t *testing.T) {
 	}
 }
 
+func TestRequestContentTypeNoDefault(t *testing.T) {
+	t.Parallel()
+
+	var h RequestHeader
+	h.SetMethod(MethodDelete)
+	h.SetNoDefaultContentType(true)
+
+	w := &bytes.Buffer{}
+	bw := bufio.NewWriter(w)
+	if err := h.Write(bw); err != nil {
+		t.Fatalf("Unexpected error: %s", err)
+	}
+	if err := bw.Flush(); err != nil {
+		t.Fatalf("Unexpected error: %s", err)
+	}
+
+	var h1 RequestHeader
+	br := bufio.NewReader(w)
+	if err := h1.Read(br); err != nil {
+		t.Fatalf("Unexpected error: %s", err)
+	}
+
+	if string(h1.contentType) != "" {
+		t.Fatalf("unexpected Content-Type %q. Expecting %q", h1.contentType, "")
+	}
+}
+
 func TestResponseDateNoDefaultNotEmpty(t *testing.T) {
 	t.Parallel()
Repository: sqlc-dev/sqlc
Pull request #3913 (2025-04-01 04:12:04)

fix(pgx): Do not wrap nil error
When wrapping errors, add a nil check before wrapping the error.

Fixes https://github.com/sqlc-dev/sqlc/issues/3912


Patch:
diff --git a/internal/codegen/golang/templates/pgx/queryCode.tmpl b/internal/codegen/golang/templates/pgx/queryCode.tmpl
index fb43db46a..59a88c880 100644
--- a/internal/codegen/golang/templates/pgx/queryCode.tmpl
+++ b/internal/codegen/golang/templates/pgx/queryCode.tmpl
@@ -89,7 +89,14 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, db DBTX, {{.Arg.Pair}}) e
 func (q *Queries) {{.MethodName}}(ctx context.Context, {{.Arg.Pair}}) error {
 	_, err := q.db.Exec(ctx, {{.ConstantName}}, {{.Arg.Params}})
 {{- end}}
-	return {{if $.WrapErrors}}fmt.Errorf("query {{.MethodName}}: %w", err){{else}}err{{end}}
+	{{- if $.WrapErrors }}
+	if err != nil {
+		return fmt.Errorf("query {{.MethodName}}: %w", err)
+	}
+	return nil
+	{{- else }}
+	return err
+	{{- end }}
 }
 {{end}}
 


Test patch:
diff --git a/internal/endtoend/testdata/wrap_errors/postgresql/pgx/db/query.sql.go b/internal/endtoend/testdata/wrap_errors/postgresql/pgx/db/query.sql.go
index 3da47fd61..fa8c929bc 100644
--- a/internal/endtoend/testdata/wrap_errors/postgresql/pgx/db/query.sql.go
+++ b/internal/endtoend/testdata/wrap_errors/postgresql/pgx/db/query.sql.go
@@ -44,7 +44,10 @@ WHERE id = $1
 
 func (q *Queries) DeleteAuthorExec(ctx context.Context, id int64) error {
 	_, err := q.db.Exec(ctx, deleteAuthorExec, id)
-	return fmt.Errorf("query DeleteAuthorExec: %w", err)
+	if err != nil {
+		return fmt.Errorf("query DeleteAuthorExec: %w", err)
+	}
+	return nil
 }
 
 const deleteAuthorExecLastID = `-- name: DeleteAuthorExecLastID :execlastid
Repository: sqlc-dev/sqlc
Pull request #2901 (2023-10-23 20:07:40)

feat(config): Remove managed database validation
Catch the unauthenticated error from the service instead.


Patch:
diff --git a/internal/config/validate.go b/internal/config/validate.go
index dd17b2aa3..fadef4fb3 100644
--- a/internal/config/validate.go
+++ b/internal/config/validate.go
@@ -6,14 +6,6 @@ func Validate(c *Config) error {
 			if sql.Database.URI == "" && !sql.Database.Managed {
 				return ErrInvalidDatabase
 			}
-			if sql.Database.Managed {
-				if c.Cloud.Project == "" {
-					return ErrManagedDatabaseNoProject
-				}
-				if c.Cloud.AuthToken == "" {
-					return ErrManagedDatabaseNoAuthToken
-				}
-			}
 		}
 	}
 	return nil


Test patch:
diff --git a/internal/endtoend/testdata/star_expansion_series/postgresql/pgx/sqlc.yaml b/internal/endtoend/testdata/star_expansion_series/postgresql/pgx/sqlc.yaml
index 2f1271592..5dc63e3f9 100644
--- a/internal/endtoend/testdata/star_expansion_series/postgresql/pgx/sqlc.yaml
+++ b/internal/endtoend/testdata/star_expansion_series/postgresql/pgx/sqlc.yaml
@@ -1,6 +1,4 @@
 version: "2"
-cloud:
-  project: "01HAQMMECEYQYKFJN8MP16QC41"
 sql:
   - engine: "postgresql"
     schema: "schema.sql"
@@ -10,5 +8,3 @@ sql:
         package: "querytest"
         out: "go"
         sql_package: "pgx/v5"
-    database:
-      managed: true
Repository: sqlc-dev/sqlc
Pull request #2942 (2023-11-03 18:02:04)

fix(compiler): Prevent panic when compiler is nil
Resolves https://github.com/sqlc-dev/sqlc/issues/2939


Patch:
diff --git a/internal/cmd/generate.go b/internal/cmd/generate.go
index 0865705db..0dd097049 100644
--- a/internal/cmd/generate.go
+++ b/internal/cmd/generate.go
@@ -348,7 +348,11 @@ func remoteGenerate(ctx context.Context, configPath string, conf *config.Config,
 func parse(ctx context.Context, name, dir string, sql config.SQL, combo config.CombinedSettings, parserOpts opts.Parser, stderr io.Writer) (*compiler.Result, bool) {
 	defer trace.StartRegion(ctx, "parse").End()
 	c, err := compiler.NewCompiler(sql, combo)
-	defer c.Close(ctx)
+	defer func() {
+		if c != nil {
+			c.Close(ctx)
+		}
+	}()
 	if err != nil {
 		fmt.Fprintf(stderr, "error creating compiler: %s\n", err)
 		return nil, true


Test patch:
diff --git a/internal/endtoend/testdata/bad_config/engine/query.sql b/internal/endtoend/testdata/bad_config/engine/query.sql
new file mode 100644
index 000000000..18b0c0d03
--- /dev/null
+++ b/internal/endtoend/testdata/bad_config/engine/query.sql
@@ -0,0 +1,2 @@
+-- name: Test :exec
+SELECT 1;
\ No newline at end of file
diff --git a/internal/endtoend/testdata/bad_config/engine/sqlc.yaml b/internal/endtoend/testdata/bad_config/engine/sqlc.yaml
new file mode 100644
index 000000000..8f20b4eaa
--- /dev/null
+++ b/internal/endtoend/testdata/bad_config/engine/sqlc.yaml
@@ -0,0 +1,8 @@
+version: 2
+sql:
+- queries: query.sql
+  schema: query.sql
+  engine: "bad_engine"
+  gen:
+    go:
+      out: "db"
\ No newline at end of file
diff --git a/internal/endtoend/testdata/bad_config/engine/stderr.txt b/internal/endtoend/testdata/bad_config/engine/stderr.txt
new file mode 100644
index 000000000..979724492
--- /dev/null
+++ b/internal/endtoend/testdata/bad_config/engine/stderr.txt
@@ -0,0 +1,1 @@
+error creating compiler: unknown engine: bad_engine
\ No newline at end of file
Repository: brightcove/hot-shots
Pull request #81 (2018-07-26 13:20:54)

asyncTimer
introduction of function which understands async return and instruments appropriately 

should resolve https://github.com/brightcove/hot-shots/issues/66


Patch:
diff --git a/lib/statsFunctions.js b/lib/statsFunctions.js
index 6a66747..bd82a2b 100644
--- a/lib/statsFunctions.js
+++ b/lib/statsFunctions.js
@@ -48,6 +48,42 @@ function applyStatsFns (Client) {
     };
   };
 
+  /**
+   * Decorates an async function with timing recording behaviour.
+   *
+   * This version of `timer` will record the time take for the asyncronus action returned by `func`
+   * not just the execution time of `func` itself.
+   *
+   * @param func {<T,A>(...A):Promise<T>} The function to run
+   * @param stat {String|Array} The stat(s) to send
+   * @param sampleRate {Number=} The Number of times to sample (0 to 1). Optional.
+   * @param tags {Array=} The Array of tags to add to metrics. Optional.
+   * @param callback {Function=} Callback when message is done being delivered. Optional.
+   */
+  Client.prototype.asyncTimer = function (func, stat, sampleRate, tags, callback) {
+    var self = this;
+    return function() {
+      var end = hrtimer();
+      var p = func.apply(null, arguments);
+      var recordStat = function() { self.timing(stat, end(), sampleRate, tags, callback); };
+      p.then(recordStat, recordStat);
+      return p;
+    };
+  };
+
+  function hrtimer() {
+    var start = process.hrtime();
+
+    return function () {
+      var durationComponents = process.hrtime(start);
+      var seconds = durationComponents[0];
+      var nanoseconds = durationComponents[1];
+      var duration = seconds * 1000 + nanoseconds / 1E6;
+      return duration;
+    };
+  }
+
+
   /**
    * Increments a stat by a specified amount
    * @param stat {String|Array} The stat(s) to send
@@ -267,4 +303,4 @@ function applyStatsFns (Client) {
   };
 }
 
-module.exports = applyStatsFns;
\ No newline at end of file
+module.exports = applyStatsFns;


Test patch:
diff --git a/test/timer.js b/test/timer.js
index d381328..24cae59 100644
--- a/test/timer.js
+++ b/test/timer.js
@@ -1,5 +1,5 @@
 'use strict';
-
+var StatsD = require('../lib/statsd');
 var assert = require('assert');
 
 var createStatsdClient = require('./helpers').createStatsdClient;
@@ -105,5 +105,32 @@ module.exports = function runTimerTestSuite() {
         });
       });
     });
+
+    it('should record "user time" of promise', function () {
+      /* globals Promise */
+      var statsd = new StatsD({mock:true});
+
+      var onehundredMsFunc = function () { return delay(100); };
+
+      var instrumented = statsd.asyncTimer(onehundredMsFunc, 'name-thingy');
+
+      return instrumented().then(function() {
+
+        var stat = statsd.mockBuffer[0];
+        var name = stat.split(/:|\|/)[0];
+        var time = stat.split(/:|\|/)[1];
+
+        assert.equal(name, 'name-thingy');
+        assert.ok(parseFloat(time) >= 100);
+        assert.ok(parseFloat(time) < 200);
+      });
+    });
   });
 };
+
+
+function delay(n) {
+  return new Promise(function (resolve, reject) {
+    setTimeout(resolve, n);
+  });
+}
Repository: brightcove/hot-shots
Pull request #118 (2019-09-09 22:12:02)

Fix cacheDns option when obtaining host from DD_AGENT_HOST
Look up `this.host`, not `options.host`, so that caching works when the host is obtained from the `DD_AGENT_HOST` environment variable or the default value of `"localhost"` is used. `this.host` is initialized with `options.host || process.env.DD_AGENT_HOST || 'localhost'`.


Patch:
diff --git a/lib/statsd.js b/lib/statsd.js
index 0363540..51edab9 100644
--- a/lib/statsd.js
+++ b/lib/statsd.js
@@ -137,7 +137,7 @@ const Client = function (host, port, prefix, suffix, globalize, cacheDns, mock,
       this.dnsError = options.dnsError;
     }
   } else if (options.cacheDns === true) {
-    dns.lookup(options.host, (err, address) => {
+    dns.lookup(this.host, (err, address) => {
       if (err === null) {
         self.host = address;
       } else {


Test patch:
diff --git a/test/init.js b/test/init.js
index 3a136b2..6e0b093 100644
--- a/test/init.js
+++ b/test/init.js
@@ -166,6 +166,24 @@ describe('#init', () => {
     statsd = createHotShotsClient({ host: 'localhost', cacheDns: true }, clientType);
   });
 
+  it('should attempt to cache a dns record if dnsCache is specified and DD_AGENT_HOST is set', done => {
+    const originalLookup = dns.lookup;
+
+    // Replace the dns lookup function with our mock dns lookup
+    dns.lookup = (host, callback) => {
+      process.nextTick(() => {
+        dns.lookup = originalLookup;
+        assert.equal(statsd.host, host);
+        callback(null, '127.0.0.1', 4);
+        assert.equal(statsd.host, '127.0.0.1');
+        done();
+      });
+    };
+
+    process.env.DD_AGENT_HOST = 'localhost';
+    statsd = createHotShotsClient({ cacheDns: true }, clientType);
+  });
+
   it('should not attempt to cache a dns record if dnsCache is not specified', done => {
     const originalLookup = dns.lookup;
Repository: braintree/braintree-web-drop-in
Pull request #648 (2020-08-13 15:25:26)

Fix issue where 3ds info was not being passed in payload
### Summary

We failed to actually send along the 3ds info in the request payment payload 😨 

### Checklist

- [x] Added a changelog entry

### Authors
> List GitHub usernames for everyone who contributed to this pull request.

- @crookedneighbor 



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 696cfd7..e774811 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ unreleased
 - Update @braintree/class-list to v0.2.0
 - Update @braintree/event-emitter to v0.4.0
 - Update @braintree/wrap-promise to v2.1.0
+- Fix issue where `threeDSecureInfo` was not included in `requestPaymentMethod` payload
 
 1.23.0
 ------
diff --git a/src/dropin.js b/src/dropin.js
index 95e24df..a1535f5 100644
--- a/src/dropin.js
+++ b/src/dropin.js
@@ -866,6 +866,10 @@ function formatPaymentMethodPayload(paymentMethod) {
     formattedPaymentMethod.liabilityShiftPossible = paymentMethod.liabilityShiftPossible;
   }
 
+  if (paymentMethod.threeDSecureInfo) {
+    formattedPaymentMethod.threeDSecureInfo = paymentMethod.threeDSecureInfo;
+  }
+
   if (paymentMethod.deviceData) {
     formattedPaymentMethod.deviceData = paymentMethod.deviceData;
   }


Test patch:
diff --git a/test/unit/dropin.js b/test/unit/dropin.js
index 121868c..c7bcee0 100644
--- a/test/unit/dropin.js
+++ b/test/unit/dropin.js
@@ -1411,10 +1411,9 @@ describe('Dropin', () => {
           expect(payload.nonce).toBe('new-nonce');
           expect(payload.liabilityShifted).toBe(true);
           expect(payload.liabilityShiftPossible).toBe(true);
-          expect(fakePayload.nonce).toBe('new-nonce');
-          expect(fakePayload.liabilityShifted).toBe(true);
-          expect(fakePayload.liabilityShiftPossible).toBe(true);
-          expect(fakePayload.threeDSecureInfo.threeDSecureAuthenticationId).toBe('id');
+          expect(payload.liabilityShifted).toBe(true);
+          expect(payload.liabilityShiftPossible).toBe(true);
+          expect(payload.threeDSecureInfo.threeDSecureAuthenticationId).toBe('id');
 
           done();
         });
Repository: braintree/braintree-web-drop-in
Pull request #684 (2021-01-08 16:58:15)

feat: add support for Venmo Desktop
### Summary

* Adds `allowDesktop` configuration to venmo in Drop-in demo.
* Handles a customer cancelling the desktop flow

### Checklist

- [ ] ~~Added a changelog entry~~ Should we add this to the changelog?

### Authors
> List GitHub usernames for everyone who contributed to this pull request.

- @crookedneighbor 



Patch:
diff --git a/src/views/payment-sheet-views/venmo-view.js b/src/views/payment-sheet-views/venmo-view.js
index 355707a..5b7ccc0 100644
--- a/src/views/payment-sheet-views/venmo-view.js
+++ b/src/views/payment-sheet-views/venmo-view.js
@@ -70,7 +70,7 @@ VenmoView.prototype._isIgnorableError = function (error) {
   // customer cancels the flow in the app
   // we don't emit an error because the customer
   // initiated that action
-  return error.code === 'VENMO_APP_CANCELED';
+  return error.code === 'VENMO_APP_CANCELED' || error.code === 'VENMO_DESKTOP_CANCELED';
 };
 
 VenmoView.isEnabled = function (options) {


Test patch:
diff --git a/test/app/index.html b/test/app/index.html
index 3205424..3d1f522 100644
--- a/test/app/index.html
+++ b/test/app/index.html
@@ -144,6 +144,9 @@
         totalPrice: '19.99'
       }
     },
+    venmo: {
+      allowDesktop: true
+    },
     vaultManager: true
   };
   var dropinInstance;
diff --git a/test/unit/views/payment-sheet-views/venmo-view.js b/test/unit/views/payment-sheet-views/venmo-view.js
index 16103d7..f62b255 100644
--- a/test/unit/views/payment-sheet-views/venmo-view.js
+++ b/test/unit/views/payment-sheet-views/venmo-view.js
@@ -161,6 +161,24 @@ describe('VenmoView', () => {
       }
     );
 
+    test(
+      'does not report app switch error for VENMO_DESKTOP_CANCELLED error',
+      () => {
+        const error = new Error('failure');
+
+        error.code = 'VENMO_DESKTOP_CANCELED';
+
+        testContext.fakeVenmoInstance.hasTokenizationResult.mockReturnValue(true);
+        testContext.fakeVenmoInstance.tokenize.mockRejectedValue(error);
+
+        return testContext.view.initialize().then(() => {
+          expect(testContext.fakeVenmoInstance.tokenize).toBeCalledTimes(1);
+          expect(testContext.model.reportAppSwitchError).not.toBeCalled();
+          expect(testContext.model.reportAppSwitchPayload).not.toBeCalled();
+        });
+      }
+    );
+
     test(
       'calls asyncDependencyFailed when Venmo component creation fails',
       () => {