-
Notifications
You must be signed in to change notification settings - Fork 168
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
[unit-tests-only] Implemented todo
unit tests for route helper
#5795
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
@@ -1,48 +1,100 @@ | ||
import { | ||
checkRoute, | ||
isAnySharedWithRoute, | ||
isFavoritesRoute, | ||
isPersonalRoute, | ||
isPublicFilesRoute, | ||
isPublicPage, | ||
isSharedWithMeRoute, | ||
isSharedWithOthersRoute, | ||
isTrashbinRoute | ||
} from '@files/src/helpers/route.js' | ||
|
||
describe('route', () => { | ||
describe('checkRoute', () => { | ||
it.todo('should return "true" if given "routes" array contains given "currentRoute"') | ||
it.todo('should return "false" if given "routes" array does not contains given "currentRoute"') | ||
it('should return "true" if given "routes" array contains given "currentRoute"', () => { | ||
expect(checkRoute(['some-route'], 'some-route')).toBe(true) | ||
}) | ||
it('should return "false" if given "routes" array does not contains given "currentRoute"', () => { | ||
expect(checkRoute(['some-route'], 'another-route')).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isPersonalRoute', () => { | ||
it.todo('should return "true" if given route name is "files-personal"') | ||
it.todo('should return "false" if given route name is not "files-personal"') | ||
it('should return "true" if given route name is "files-personal"', () => { | ||
expect(isPersonalRoute({ name: 'files-personal' })).toBe(true) | ||
}) | ||
it('should return "false" if given route name is not "files-personal"', () => { | ||
expect(isPersonalRoute({ name: 'files-favorites' })).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isFavoritesRoute', () => { | ||
it.todo('should return "true" if given route name is "files-favorites"') | ||
it.todo('should return "false" if given route name is not "files-favorites"') | ||
it('should return "true" if given route name is "files-favorites"', () => { | ||
expect(isFavoritesRoute({ name: 'files-favorites' })).toBe(true) | ||
}) | ||
it('should return "false" if given route name is not "files-favorites"', () => { | ||
expect(isFavoritesRoute({ name: 'files-personal' })).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isTrashbinRoute', () => { | ||
it.todo('should return "true" if given route name is "files-trashbin"') | ||
it.todo('should return "false" if given route name is not "files-trashbin"') | ||
it('should return "true" if given route name is "files-trashbin"', () => { | ||
expect(isTrashbinRoute({ name: 'files-trashbin' })).toBe(true) | ||
}) | ||
it('should return "false" if given route name is not "files-trashbin"', () => { | ||
expect(isTrashbinRoute({ name: 'files-personal' })).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isSharedWithMeRoute', () => { | ||
it.todo('should return "true" if given route name is "files-shared-with-me"') | ||
it.todo('should return "false" if given route name is not "files-shared-with-me"') | ||
it('should return "true" if given route name is "files-shared-with-me"', () => { | ||
expect(isSharedWithMeRoute({ name: 'files-shared-with-me' })).toBe(true) | ||
}) | ||
it('should return "false" if given route name is not "files-shared-with-me"', () => { | ||
expect(isSharedWithMeRoute({ name: 'files-personal' })).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isSharedWithOthersRoute', () => { | ||
it.todo('should return "true" if given route name is "files-shared-with-others"') | ||
it.todo('should return "false" if given route name is not "files-shared-with-others"') | ||
it('should return "true" if given route name is "files-shared-with-others"', () => { | ||
expect(isSharedWithOthersRoute({ name: 'files-shared-with-others' })).toBe(true) | ||
}) | ||
it('should return "false" if given route name is not "files-shared-with-others"', () => { | ||
expect(isSharedWithOthersRoute({ name: 'files-shared-with-me' })).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isAnySharedWithRoute', () => { | ||
it.todo('should return "false" if given route is not "SharedWithMe" and "SharedWithOthers"') | ||
it.todo('should return "true" if given route is "SharedWithMe"') | ||
it.todo('should return "true" if given route is "SharedWithOthers"') | ||
it('should return "false" if given route is not "SharedWithMe" and "SharedWithOthers"', () => { | ||
expect(isAnySharedWithRoute({ name: 'files-personal' })).toBe(false) | ||
}) | ||
it('should return "true" if given route is "SharedWithMe"', () => { | ||
expect(isAnySharedWithRoute({ name: 'files-shared-with-me' })).toBe(true) | ||
}) | ||
it('should return "true" if given route is "SharedWithOthers"', () => { | ||
expect(isAnySharedWithRoute({ name: 'files-shared-with-others' })).toBe(true) | ||
}) | ||
}) | ||
|
||
describe('isPublicFilesRoute', () => { | ||
it.todo('should return "true" if given route name is "files-public-list"') | ||
it.todo('should return "false" if given route name is not "files-public-list"') | ||
it('should return "true" if given route name is "files-public-list"', () => { | ||
expect(isPublicFilesRoute({ name: 'files-public-list' })).toBe(true) | ||
}) | ||
it('should return "false" if given route name is not "files-public-list"', () => { | ||
expect(isPublicFilesRoute({ name: 'files-shared-with-others' })).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('isPublicPage', () => { | ||
it.todo('should return "false" if given route has no meta information') | ||
it.todo('should return "false" if given route meta auth is "true"') | ||
it.todo('should return "true" if given route meta auth is "false"') | ||
it('should return "false" if given route has no meta information', () => { | ||
expect(isPublicPage({ name: 'files-public-list' })).toBe(false) | ||
}) | ||
it('should return "false" if given route meta auth is "true"', () => { | ||
expect(isPublicPage({ meta: { auth: true } })).toBe(false) | ||
}) | ||
it('should return "true" if given route meta auth is "false"', () => { | ||
expect(isPublicPage({ meta: { auth: false } })).toBe(true) | ||
}) | ||
}) | ||
}) |
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.
files-public-list returns
false
when checked if it is a public page? 🤔 we need to check our code, it's not the test that is falsy I think