Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
63dcbc7
style: TT-332 include Tailwind in global style file
JosueOb Sep 2, 2021
5a5f6f9
feat: TT-332 dark mode implementation
JosueOb Sep 3, 2021
b017fbd
style: TT-332 color palette
JosueOb Sep 6, 2021
2d648d7
test: TT-332 unit test on the dark mode component
JosueOb Sep 6, 2021
1e23038
fix: TT-216 add tabIndex attribute to materialDatePicker and to Date …
bytesantiago Sep 7, 2021
13fd98a
chore(release): 1.50.5 [skip ci]nn
semantic-release-bot Sep 7, 2021
c63a8a0
refactor: TT-332 application of Azure toggle function to display dark…
JosueOb Sep 8, 2021
8e1ec7e
style: TT-332 TW prefix added to the color palette
JosueOb Sep 8, 2021
181bc76
refactor: TT-332 changes in sidebar and dark mode components
JosueOb Sep 8, 2021
704ba0e
fix: TT-334 keep the sidebar item selected when the page is refreshed…
JosueOb Sep 9, 2021
0125ac6
chore(release): 1.50.6 [skip ci]nn
semantic-release-bot Sep 9, 2021
5ecda54
refactor: TT-332 changes to the button to change the page theme
JosueOb Sep 10, 2021
f6fd309
test: TT-332 unit test to check if the user has the dark-mode feature…
JosueOb Sep 11, 2021
ff1ded3
style: TT-332 include Tailwind in global style file
JosueOb Sep 2, 2021
419ff2b
feat: TT-332 dark mode implementation
JosueOb Sep 3, 2021
c4ac6f7
style: TT-332 color palette
JosueOb Sep 6, 2021
57f96d7
test: TT-332 unit test on the dark mode component
JosueOb Sep 6, 2021
1507382
refactor: TT-332 application of Azure toggle function to display dark…
JosueOb Sep 8, 2021
18997af
style: TT-332 TW prefix added to the color palette
JosueOb Sep 8, 2021
1ed1c33
refactor: TT-332 changes in sidebar and dark mode components
JosueOb Sep 8, 2021
b99fa46
refactor: TT-332 changes to the button to change the page theme
JosueOb Sep 10, 2021
1e2e392
test: TT-332 unit test to check if the user has the dark-mode feature…
JosueOb Sep 11, 2021
b8705dd
refactor: TT-332 changes in the unit test description of the dark mod…
JosueOb Sep 13, 2021
95d1ed3
refactor: TT-332 changes in the unit test description of the dark mod…
JosueOb Sep 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: TT-332 unit test on the dark mode component
  • Loading branch information
JosueOb committed Sep 6, 2021
commit 2d648d767679ff4d3562c67de4fd84838529e5b4
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ describe('DarkModeComponent', () => {
expect(component.theme).toBe('light');
});

it('should be light theme if only the theme property exists in local storage and not its value', () => {
localStorage.setItem('theme', '');
component.checkThemeInLocalStorage();
expect(component.theme).toBe('light');
});

it('should switch to dark theme if the theme property is light and vice versa', () => {
component.theme = component.setTheme();
expect(component.theme).toBe('dark');
component.theme = component.setTheme();
expect(component.theme).toBe('light');
});

it('should add the dark class in the html tag to apply dark mode', () => {
component.theme = 'dark';
component.addOrRemoveDarkMode();
fixture.detectChanges();
const htmlContainsDarkClass = document.documentElement.classList.contains('dark');
expect(htmlContainsDarkClass).toBe(true);
});

it('should be changed to dark mode if the mode toggle is selected', () => {
component.themeToggle.nativeElement.click();
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class DarkModeComponent implements AfterViewInit {
return this.theme === 'dark' ? true : false;
}

setTheme(): string {
return this.isDarkTheme() ? 'light' : 'dark';
}

addOrRemoveDarkMode(): void {
if (this.isDarkTheme()) {
document.documentElement.classList.add('dark');
Expand All @@ -48,11 +52,7 @@ export class DarkModeComponent implements AfterViewInit {
}

changeToDarkOrLightTheme(): void {
if (this.isDarkTheme()) {
this.theme = 'light';
} else {
this.theme = 'dark';
}
this.theme = this.setTheme();
this.setLocalStorageTheme(this.theme);
this.switchThemeToggleStyles(this.theme);
this.addOrRemoveDarkMode();
Expand Down