Skip to content

Commit

Permalink
Implemented todo unit tests for route helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Sep 10, 2021
1 parent d7b1135 commit b83b89d
Showing 1 changed file with 72 additions and 20 deletions.
92 changes: 72 additions & 20 deletions packages/web-app-files/tests/unit/helpers/route.spec.js
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')).toBeTruthy()
})
it('should return "false" if given "routes" array does not contains given "currentRoute"', () => {
expect(checkRoute(['some-route'], 'another-route')).toBeFalsy()
})
})

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' })).toBeTruthy()
})
it('should return "false" if given route name is not "files-personal"', () => {
expect(isPersonalRoute({ name: 'files-favorites' })).toBeFalsy()
})
})

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' })).toBeTruthy()
})
it('should return "false" if given route name is not "files-favorites"', () => {
expect(isFavoritesRoute({ name: 'files-personal' })).toBeFalsy()
})
})

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' })).toBeTruthy()
})
it('should return "false" if given route name is not "files-trashbin"', () => {
expect(isTrashbinRoute({ name: 'files-personal' })).toBeFalsy()
})
})

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' })).toBeTruthy()
})
it('should return "false" if given route name is not "files-shared-with-me"', () => {
expect(isSharedWithMeRoute({ name: 'files-personal' })).toBeFalsy()
})
})

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' })).toBeTruthy()
})
it('should return "false" if given route name is not "files-shared-with-others"', () => {
expect(isSharedWithOthersRoute({ name: 'files-shared-with-me' })).toBeFalsy()
})
})

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' })).toBeFalsy()
})
it('should return "true" if given route is "SharedWithMe"', () => {
expect(isAnySharedWithRoute({ name: 'files-shared-with-me' })).toBeTruthy()
})
it('should return "true" if given route is "SharedWithOthers"', () => {
expect(isAnySharedWithRoute({ name: 'files-shared-with-others' })).toBeTruthy()
})
})

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' })).toBeTruthy()
})
it('should return "false" if given route name is not "files-public-list"', () => {
expect(isPublicFilesRoute({ name: 'files-shared-with-others' })).toBeFalsy()
})
})

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' })).toBeFalsy()
})
it('should return "false" if given route meta auth is "true"', () => {
expect(isPublicPage({ meta: { auth: true } })).toBeFalsy()
})
it('should return "true" if given route meta auth is "false"', () => {
expect(isPublicPage({ meta: { auth: false } })).toBeTruthy()
})
})
})

0 comments on commit b83b89d

Please sign in to comment.