Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Oct 7, 2019
1 parent f3d0827 commit 2303d22
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/js/test.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ global.Ziggy = {
methods: ['GET', 'HEAD'],
domain: null
},
withOptionalFilter: {
uri: 'stuff/{filter?}',
methods: ['GET', 'HEAD'],
domain: null
},
'conversations.show': {
uri:
'subscribers/{subscriber}/conversations/{type}/{conversation_id?}',
Expand Down Expand Up @@ -172,6 +177,16 @@ describe('route()', function() {
global.Ziggy.defaultParameters = defaultParameters;
});

it('Should not use array filter property as default parameter for "filter"', function() {
let defaultParameters = global.Ziggy.defaultParameters;
global.Ziggy.defaultParameters = [];
assert.equal(
'http://myapp.dev/stuff/',
route('withOptionalFilter')
);
global.Ziggy.defaultParameters = defaultParameters;
});

it('Should return missing params error when run with missing params on a route with required params and default params', function() {
assert.throws(function() {
route('translatePosts.show').toString();
Expand Down

0 comments on commit 2303d22

Please sign in to comment.