Skip to content

Commit

Permalink
test: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ModyQyW committed Aug 8, 2023
1 parent 967504c commit e12aa83
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/utils/buildUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ describe('utils::buildUrl', () => {
bar: 'baz',
},
}),
).toEqual('/foo?foo%5Bbar%5D=baz');
// ).toEqual('/foo?foo%5Bbar%5D=baz'); // qs
).toEqual('/foo?foo=%5Bobject%20Object%5D'); // query-string
});

it('should support date params', () => {
Expand All @@ -32,15 +33,19 @@ describe('utils::buildUrl', () => {
buildUrl('/foo', {
date: date,
}),
).toEqual('/foo?date=' + encodeURIComponent(date.toISOString()));
// ).toEqual('/foo?date=' + encodeURIComponent(date.toISOString())); // qs
).toEqual(
'/foo?date=' + encodeURIComponent(date.toString()).replace('(', '%28').replace(')', '%29'),
); // query-string
});

it('should support array params', () => {
expect(
buildUrl('/foo', {
foo: ['bar', 'baz'],
}),
).toEqual('/foo?foo%5B0%5D=bar&foo%5B1%5D=baz');
// ).toEqual('/foo?foo%5B0%5D=bar&foo%5B1%5D=baz'); // qs
).toEqual('/foo?foo=bar&foo=baz'); // query-string
});

it('should support special char params', () => {
Expand All @@ -66,7 +71,8 @@ describe('utils::buildUrl', () => {
start: 0,
length: 5,
}),
).toEqual('/foo?query=bar&start=0&length=5');
// ).toEqual('/foo?query=bar&start=0&length=5'); // qs
).toEqual('/foo?length=5&query=bar&start=0'); // query-string
});

it('should correct discard url hash mark', () => {
Expand Down

0 comments on commit e12aa83

Please sign in to comment.