Skip to content

Commit 7c796e1

Browse files
committed
- adding an additional test to check if the navbar is shown at the correct location
1 parent 9dd125b commit 7c796e1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/components/components/wizard.component.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {WizardComponent} from './wizard.component';
55
import {WizardStepComponent} from './wizard-step.component';
66
import {WizardNavigationBarComponent} from './wizard-navigation-bar.component';
77
import {GoToStepDirective} from '../directives/go-to-step.directive';
8+
import {By} from "@angular/platform-browser";
89

910
@Component({
1011
selector: 'test-wizard',
@@ -60,6 +61,29 @@ describe('WizardComponent', () => {
6061
expect(wizardTest).toBeTruthy();
6162
});
6263

64+
it('should contain navigation bar at the correct position', () => {
65+
// check default: the navbar should be at the top of the wizard if no navBarLocation was set
66+
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar"))).toBeTruthy();
67+
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :first-child")).name).toBe('wizard-navigation-bar');
68+
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar.top"))).toBeTruthy();
69+
70+
wizardTest.wizard.navBarLocation = "bottom";
71+
wizardTestFixture.detectChanges();
72+
73+
// navBar should be at the bottom of the wizard
74+
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar"))).toBeTruthy();
75+
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :last-child")).name).toBe('wizard-navigation-bar');
76+
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar.bottom"))).toBeTruthy();
77+
78+
wizardTest.wizard.navBarLocation = "top";
79+
wizardTestFixture.detectChanges();
80+
81+
// navBar should be at the top of the wizard
82+
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar"))).toBeTruthy();
83+
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :first-child")).name).toBe('wizard-navigation-bar');
84+
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar.top"))).toBeTruthy();
85+
});
86+
6387
it('should have steps', () => {
6488
expect(wizardTest.wizard.wizardSteps.length).toBe(3);
6589
});

0 commit comments

Comments
 (0)