forked from anihalaney/rwa-trivia
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request anihalaney#692 from milansar/BW-868
BW-868 Unit test of User, Topics, categories and tags selector
- Loading branch information
Showing
9 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
projects/shared-library/src/lib/core/store/selectors/categories.selector.spec.ts
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,18 @@ | ||
|
||
import { testData } from 'test/data'; | ||
import { categoryDictionary, getCategories } from './categories.selector'; | ||
describe('Categories:Selector', () => { | ||
const categories = testData.categoryList; | ||
const categoryDict = testData.categoryDictionary; | ||
|
||
it('getCategories', () => { | ||
const state = { core: { categories } }; | ||
expect(getCategories(state)).toBe(categories); | ||
}); | ||
|
||
it('categoryDictionary', () => { | ||
const state = { core: { categories } }; | ||
expect(categoryDictionary(state)).toEqual(categoryDict); | ||
}); | ||
}); | ||
|
2 changes: 1 addition & 1 deletion
2
projects/shared-library/src/lib/core/store/selectors/categories.selector.ts
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
10 changes: 10 additions & 0 deletions
10
projects/shared-library/src/lib/core/store/selectors/tags.selector.spec.ts
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,10 @@ | ||
|
||
import { testData } from 'test/data'; | ||
import { getTags } from './tags.selector'; | ||
describe('Tags:Selector', () => { | ||
const tags: string[] = testData.tagList; | ||
it('getTags', () => { | ||
const state = { core: { tags } }; | ||
expect(getTags(state)).toBe(tags); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
projects/shared-library/src/lib/core/store/selectors/tags.selector.ts
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
12 changes: 12 additions & 0 deletions
12
projects/shared-library/src/lib/core/store/selectors/topics.selector.spec.ts
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,12 @@ | ||
|
||
import { testData } from 'test/data'; | ||
import { getTopTopics } from './topics.selector'; | ||
import { Topic } from 'shared-library/shared/model'; | ||
describe('Topics:Selector', () => { | ||
const topTopics: Topic[] = testData.topics; | ||
|
||
it('getTopTopics', () => { | ||
const state = { core: { topTopics } }; | ||
expect(getTopTopics(state)).toBe(topTopics); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
projects/shared-library/src/lib/core/store/selectors/user.selector.spec.ts
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,23 @@ | ||
|
||
import { testData } from 'test/data'; | ||
import { authorizationHeader, getUser } from './user.selector'; | ||
describe('User:Selector', () => { | ||
const user = testData.userList[0]; | ||
|
||
it('getUser', () => { | ||
const state = { core: { user } }; | ||
expect(getUser(state)).toBe(user); | ||
}); | ||
|
||
it('getUser', () => { | ||
const state = { core: { user } }; | ||
const token = `Bearer ${user.idToken}`; | ||
expect(authorizationHeader(state)).toBe(token); | ||
}); | ||
|
||
it('authorizationHeader with null', () => { | ||
const state = { core: { user: '' } }; | ||
expect(authorizationHeader(state)).toBe(null); | ||
}); | ||
}); | ||
|
3 changes: 1 addition & 2 deletions
3
projects/shared-library/src/lib/core/store/selectors/user.selector.ts
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
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,52 @@ | ||
export const Topics = [ | ||
{ | ||
'id': 1, | ||
'categoryName': 'Bit of sci-fi', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 2, | ||
'categoryName': 'Programming', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 3, | ||
'categoryName': 'Architecture', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 4, | ||
'categoryName': 'Networking/Infrastructure', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 5, | ||
'categoryName': 'Database', | ||
'type': 'category' | ||
}, | ||
{ | ||
'id': 6, | ||
'categoryName': 'Dev Ops', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 7, | ||
'categoryName': 'UX/UI', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 8, | ||
'categoryName': 'Bit of fact', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 9, | ||
'categoryName': 'Hardware', | ||
'type': 'categories' | ||
}, | ||
{ | ||
'id': 'c', | ||
'categoryName': 'c', | ||
'type': 'tags' | ||
}, | ||
]; |