Skip to content

Commit 0be9572

Browse files
committedAug 14, 2021
[test] Test that Url#set() correctly handles the auth property
Test that when the value of the `auth` property is updated, the values of the `username` and `password` properties are also updated. Refs: #213
1 parent 15b1dbd commit 0be9572

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎test/test.js

+24
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,30 @@ describe('url-parse', function () {
10461046
assume(data.href).equals('mailto:alice@atlanta.com');
10471047
});
10481048

1049+
it('updates username and password when updating auth', function() {
1050+
var data = parse('https://example.com');
1051+
1052+
assume(data.set('auth', 'foo:bar')).equals(data);
1053+
assume(data.username).equals('foo');
1054+
assume(data.password).equals('bar');
1055+
assume(data.href).equals('https://foo:bar@example.com/');
1056+
1057+
assume(data.set('auth', 'baz:')).equals(data);
1058+
assume(data.username).equals('baz');
1059+
assume(data.password).equals('');
1060+
assume(data.href).equals('https://baz@example.com/');
1061+
1062+
assume(data.set('auth', 'qux')).equals(data);
1063+
assume(data.username).equals('qux');
1064+
assume(data.password).equals('');
1065+
assume(data.href).equals('https://qux@example.com/');
1066+
1067+
assume(data.set('auth', ':quux')).equals(data);
1068+
assume(data.username).equals('');
1069+
assume(data.password).equals('quux');
1070+
assume(data.href).equals('https://:quux@example.com/');
1071+
});
1072+
10491073
it('updates other values', function () {
10501074
var data = parse('http://google.com/?foo=bar');
10511075

0 commit comments

Comments
 (0)
Please sign in to comment.