-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement missing router functions #2393
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f6914dd
Implement missing router functions
mikemurray c157683
Fix function name for `setQueryParams`
mikemurray 7e61447
Fixes and tests
mikemurray 8e8eed6
fix package.json to run tests (#2396)
hrath2015 f905837
Merge branch 'development' into 2392-router
mikemurray 4b19bf1
Merge branch 'development' into 2392-router
brent-hoover cd5ad96
Removed comment
mikemurray 5740adc
Remove duplicated setQueryParams function
mikemurray f293306
Merge branch 'development' into 2392-router
brent-hoover File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const Blaze = { | ||
remove() {}, | ||
renderWithData() {} | ||
}; |
1 change: 1 addition & 0 deletions
1
imports/plugins/core/router/__mocks__/meteor/gadicc:blaze-react-component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default class BlazeComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const Meteor = { | ||
isClient: false, | ||
isServer: true | ||
}; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
class Dependency { | ||
depend() {} | ||
changed() {} | ||
} | ||
|
||
export const Tracker = { | ||
Dependency | ||
}; |
100 changes: 100 additions & 0 deletions
100
imports/plugins/core/router/lib/__tests__/router.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
jest.mock("/lib/collections", () => { | ||
return { | ||
Packages: {}, | ||
Shops: {} | ||
}; | ||
}); | ||
|
||
import Router from "../router.js"; | ||
|
||
beforeEach(() => { | ||
// Set some default routes | ||
Router.setCurrentRoute({}); | ||
Router.routes = [ | ||
{ | ||
fullPath: "/test?filter=red", | ||
query: { | ||
filter: "red" | ||
}, | ||
route: { | ||
name: "test", | ||
path: "/test", | ||
route: "/test" | ||
} | ||
}, | ||
{ | ||
params: { | ||
id: "a12345" | ||
}, | ||
query: { | ||
filter: "green" | ||
}, | ||
route: { | ||
fullPath: "/reaction/test/1234?filter=green", | ||
group: { | ||
prefix: "/reaction" | ||
}, | ||
name: "singleTestItem", | ||
path: "/reaction/test/12345", | ||
route: "/reaction/test/:id" | ||
} | ||
} | ||
]; | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
|
||
test("Route name to equal test", () => { | ||
// TODO: Update test when server router is implemented to use Router.go() | ||
Router.setCurrentRoute(Router.routes[0]); | ||
|
||
expect(Router.getRouteName()).toBe("test"); | ||
}); | ||
|
||
test("Route query param 'filter' to equal 'red'", () => { | ||
// TODO: Update test when server router is implemented to use Router.go() | ||
Router.setCurrentRoute(Router.routes[0]); | ||
|
||
const queryValue = Router.getQueryParam("filter"); | ||
|
||
expect(queryValue).toBe("red"); | ||
}); | ||
|
||
test("Route /test/:id param 'id' to equal '12345'", () => { | ||
// TODO: Update test when server router is implemented to use Router.go() | ||
Router.setCurrentRoute(Router.routes[1]); | ||
|
||
const received = Router.getParam("id"); | ||
|
||
expect(received).toBe("a12345"); | ||
}); | ||
|
||
test("Route is active with name 'singleTestItem'", () => { | ||
// TODO: Update test when server router is implemented to use Router.go() | ||
Router.setCurrentRoute(Router.routes[1]); | ||
|
||
const received = Router.isActiveClassName("singleTestItem"); | ||
|
||
expect(received).toBe("active"); | ||
}); | ||
|
||
test("Route /test/:id is active with prefixed path '/reaction/test/12345'", () => { | ||
// TODO: Update test when server router is implemented to use Router.go() | ||
Router.setCurrentRoute(Router.routes[1]); | ||
|
||
const received = Router.isActiveClassName("/reaction/test/12345"); | ||
|
||
expect(received).toBe("active"); | ||
}); | ||
|
||
test("Route /test is active with un-prefixed path '/test'", () => { | ||
// TODO: Update test when server router is implemented to use Router.go() | ||
Router.setCurrentRoute(Router.routes[0]); | ||
|
||
const received = Router.isActiveClassName("/test"); | ||
|
||
expect(received).toBe("active"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment relevant to every test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's relevant to every test. I can deduplicate if it's an issue.