|
34 | 34 | ok(u instanceof URI, 'instanceof URI');
|
35 | 35 | ok(u._parts.hostname !== undefined, 'host undefined');
|
36 | 36 | });
|
| 37 | + |
| 38 | + test('new URI(object)', function() { |
| 39 | + var u = new URI({ |
| 40 | + protocol: 'http', |
| 41 | + hostname: 'example.org', |
| 42 | + query: { |
| 43 | + foo: 'bar', |
| 44 | + bar: 'foo', |
| 45 | + }, |
| 46 | + }); |
| 47 | + ok(u instanceof URI, 'instanceof URI'); |
| 48 | + ok(typeof u.query() === 'string', 'query is string'); |
| 49 | + equal(u.query(), 'foo=bar&bar=foo', 'query has right value'); |
| 50 | + equal(u.search(), '?foo=bar&bar=foo', 'search has right value'); |
| 51 | + deepEqual(u.query(true), { foo: 'bar', bar: 'foo' }, 'query(true) value'); |
| 52 | + deepEqual(u.search(true), { foo: 'bar', bar: 'foo' }, 'search(true) value'); |
| 53 | + }); |
| 54 | + test('new URI(object)', function() { |
| 55 | + var u = new URI({ |
| 56 | + protocol: 'http', |
| 57 | + hostname: 'example.org', |
| 58 | + query: 'foo=bar&bar=foo', |
| 59 | + }); |
| 60 | + ok(u instanceof URI, 'instanceof URI'); |
| 61 | + ok(typeof u.query() === 'string', 'query is string'); |
| 62 | + equal(u.query(), 'foo=bar&bar=foo', 'query has right value'); |
| 63 | + equal(u.search(), '?foo=bar&bar=foo', 'search has right value'); |
| 64 | + deepEqual(u.query(true), { foo: 'bar', bar: 'foo' }, 'query(true) value'); |
| 65 | + deepEqual(u.search(true), { foo: 'bar', bar: 'foo' }, 'search(true) value'); |
| 66 | + }); |
| 67 | + test('new URI(object)', function() { |
| 68 | + var u = new URI({ |
| 69 | + protocol: 'http', |
| 70 | + hostname: 'example.org', |
| 71 | + query: '?foo=bar&bar=foo', |
| 72 | + }); |
| 73 | + ok(u instanceof URI, 'instanceof URI'); |
| 74 | + ok(typeof u.query() === 'string', 'query is string'); |
| 75 | + equal(u.query(), 'foo=bar&bar=foo', 'query has right value'); |
| 76 | + equal(u.search(), '?foo=bar&bar=foo', 'search has right value'); |
| 77 | + deepEqual(u.query(true), { foo: 'bar', bar: 'foo' }, 'query(true) value'); |
| 78 | + deepEqual(u.search(true), { foo: 'bar', bar: 'foo' }, 'search(true) value'); |
| 79 | + }); |
37 | 80 | test('new URI(Location)', function () {
|
38 | 81 | var u = new URI(location);
|
39 | 82 | equal(u.href(), String(location.href), 'location object');
|
|
0 commit comments