Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerkretzmar committed May 16, 2024
1 parent 39a13c6 commit 24a0724
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/js/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,26 @@ describe('route()', () => {
expect(route('catalog-domain-param-path', ['/p/test'], false)).toBe('/catalog//p/test');
});

// Highest potential for "breaking" changes when fixing these is the second format in each example, where
// params are passed as an array, because it's less clear in that case which param is which since we're
// relying on the order they're passed. It may break some people's code but it's probably more
// important to match Laravel's behaviour correctly, this is a pretty big inconsistency.
test('handle domain parameters when generating relative URL', () => {
// Just for demonstration purposes, this is tested properly elsewhere
expect(route('team.user.show', { team: 1, id: 2 })).toBe('https://1.ziggy.dev/users/2');
expect(route('team.user.show', [1, 2])).toBe('https://1.ziggy.dev/users/2');

// Laravel route() errors here, domain {team} param is required
// We should *probably* match that behaviour and error too
expect(route('team.user.show', { id: 2 }, false)).toBe('/users/2');
expect(route('team.user.show', [2], false)).toBe('/users/2');

// Laravel route() handles these find, {team} param is recognized even though final output won't contain it
// We should *definitely* match that behaviour and handle these properly
expect(route('team.user.show', { team: 1, id: 2 }, false)).toBe('/users/2');

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.1, Laravel 9

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.1, Laravel 10

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.2, Laravel 9

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.2, Laravel 10

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.3, Laravel 9

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.3, Laravel 10

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68

Check failure on line 810 in tests/js/route.test.js

View workflow job for this annotation

GitHub Actions / Ubuntu, PHP 8.3, Laravel 11

tests/js/route.test.js > route() > handle domain parameters when generating relative URL

AssertionError: expected '/users/2?team=1' to be '/users/2' // Object.is equality - Expected + Received - /users/2 + /users/2?team=1 ❯ tests/js/route.test.js:810:68
expect(route('team.user.show', [1, 2], false)).toBe('/users/2');
});

test('skip encoding some characters in route parameters', () => {
// Laravel doesn't encode these characters in route parameters: / @ : ; , = + ! * | ? & # %
expect(route('pages', 'a/b')).toBe('https://ziggy.dev/a/b');
Expand Down

0 comments on commit 24a0724

Please sign in to comment.