Skip to content

Commit 6f05a82

Browse files
authored
Remove bad directive selectors (#57)
- remove the alternative directive selectors selected, optional and reset - modify tests to work with the removal of the directive selectors reset, selected and optional
1 parent 14f4268 commit 6f05a82

7 files changed

+14
-41
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,13 @@ Be aware, that you can only use `[wizardStepTitle]` together with Angular, becau
269269

270270
### \[optionalStep\]
271271
If you need to define an optional step, that doesn't need to be done to continue to the next steps, you can define an optional step
272-
by adding the `optionalStep` directive to the step you want to declare as optional.
273-
To add the `optionalStep` directive to a wizard step, you can either add `optional` or `optionalStep` to the step definition.
272+
by adding the `optionalStep` directive to the step you want to declare as optional.
274273

275274
### \[selectedStep\]
276275
In some cases it may be a better choice to set the default wizard step not via a static number.
277276
Another way to set the default wizard step is by using the `selectedStep` directive.
278277
When attaching the `selectedStep` directive to an arbitrary wizard step, it will be marked as the default wizard step,
279278
which is shown directly after the wizard startup.
280-
To add the `selectedStep` directive to a wizard step, you can either add `selected` or `selectedStep` to the step definition.
281279

282280
### \[goToStep\]
283281
`ng2-archwizard` has three directives, that allow moving between steps.

src/directives/optional-step.directive.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {NavigationMode} from '../navigation/navigation-mode.interface';
1313
<wizard-step stepTitle='Steptitle 1'>
1414
Step 1
1515
</wizard-step>
16-
<wizard-step stepTitle='Steptitle 2' optional>
16+
<wizard-step stepTitle='Steptitle 2' optionalStep>
1717
Step 2
1818
</wizard-step>
1919
<wizard-step stepTitle='Steptitle 3'>

src/directives/optional-step.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {WizardStep} from '../util/wizard-step.interface';
2424
* @author Marc Arndt
2525
*/
2626
@Directive({
27-
selector: '[optional], [optionalStep]'
27+
selector: '[optionalStep]'
2828
})
2929
export class OptionalStepDirective implements OnInit {
3030
/**

src/directives/reset-wizard.directive.spec.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {ResetWizardDirective} from './reset-wizard.directive';
1818
Step 2
1919
<button type="button" resetWizard>Reset (normal)</button>
2020
<button type="button" resetWizard (finalize)='cleanup()'>Reset (cleanup)</button>
21-
<button type="button" reset (finalize)='cleanup()'>Reset (cleanup short)</button>
2221
</wizard-step>
2322
</wizard>
2423
`
@@ -56,10 +55,10 @@ describe('ResetWizardDirective', () => {
5655

5756
it('should create an instance', () => {
5857
expect(wizardTestFixture.debugElement.query(By.directive(ResetWizardDirective))).toBeTruthy();
59-
expect(wizardTestFixture.debugElement.queryAll(By.directive(ResetWizardDirective)).length).toBe(3);
58+
expect(wizardTestFixture.debugElement.queryAll(By.directive(ResetWizardDirective)).length).toBe(2);
6059
});
6160

62-
it('should reset the wizard correctly 1', fakeAsync(() => {
61+
it('should reset the wizard correctly without finalize input', fakeAsync(() => {
6362
let resetButtons = wizardTestFixture.debugElement
6463
.queryAll(By.directive(ResetWizardDirective));
6564

@@ -84,7 +83,7 @@ describe('ResetWizardDirective', () => {
8483
expect(wizardTest.eventLog).toEqual([]);
8584
}));
8685

87-
it('should reset the wizard correctly 2', fakeAsync(() => {
86+
it('should reset the wizard correctly with finalize input', fakeAsync(() => {
8887
let resetButtons = wizardTestFixture.debugElement
8988
.queryAll(By.directive(ResetWizardDirective));
9089

@@ -108,29 +107,4 @@ describe('ResetWizardDirective', () => {
108107
expect(wizardState.getStepAtIndex(1).completed).toBe(false);
109108
expect(wizardTest.eventLog).toEqual(['Cleanup done!']);
110109
}));
111-
112-
it('should reset the wizard correctly 3', fakeAsync(() => {
113-
let resetButtons = wizardTestFixture.debugElement
114-
.queryAll(By.directive(ResetWizardDirective));
115-
116-
navigationMode.goToStep(1);
117-
tick();
118-
wizardTestFixture.detectChanges();
119-
120-
expect(wizardState.getStepAtIndex(0).selected).toBe(false);
121-
expect(wizardState.getStepAtIndex(0).completed).toBe(true);
122-
expect(wizardState.getStepAtIndex(1).selected).toBe(true);
123-
expect(wizardState.getStepAtIndex(1).completed).toBe(false);
124-
expect(wizardTest.eventLog).toEqual([]);
125-
126-
resetButtons[2].nativeElement.click();
127-
tick();
128-
wizardTestFixture.detectChanges();
129-
130-
expect(wizardState.getStepAtIndex(0).selected).toBe(true);
131-
expect(wizardState.getStepAtIndex(0).completed).toBe(false);
132-
expect(wizardState.getStepAtIndex(1).selected).toBe(false);
133-
expect(wizardState.getStepAtIndex(1).completed).toBe(false);
134-
expect(wizardTest.eventLog).toEqual(['Cleanup done!']);
135-
}));
136110
});

src/directives/reset-wizard.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {NavigationMode} from '../navigation/navigation-mode.interface';
1515
* @author Marc Arndt
1616
*/
1717
@Directive({
18-
selector: '[reset], [resetWizard]'
18+
selector: '[resetWizard]'
1919
})
2020
export class ResetWizardDirective {
2121
/**

src/directives/selected-step.directive.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {By} from '@angular/platform-browser';
44
import {ArchwizardModule} from '../archwizard.module';
55
import {WizardState} from '../navigation/wizard-state.model';
66
import {NavigationMode} from '../navigation/navigation-mode.interface';
7+
import {SelectedStepDirective} from './selected-step.directive';
78

89
@Component({
910
selector: 'test-wizard',
@@ -12,7 +13,7 @@ import {NavigationMode} from '../navigation/navigation-mode.interface';
1213
<wizard-step stepTitle='Steptitle 1'>
1314
Step 1
1415
</wizard-step>
15-
<wizard-step stepTitle='Steptitle 2' selected>
16+
<wizard-step stepTitle='Steptitle 2' selectedStep>
1617
Step 2
1718
</wizard-step>
1819
<wizard-step stepTitle='Steptitle 3'>
@@ -48,16 +49,16 @@ describe('SelectedStepDirective', () => {
4849
});
4950

5051
it('should create an instance', () => {
51-
expect(wizardTestFixture.debugElement.query(By.css('wizard-step[selected]'))).toBeTruthy();
52-
expect(wizardTestFixture.debugElement.queryAll(By.css('wizard-step[selected]')).length).toBe(1);
52+
expect(wizardTestFixture.debugElement.query(By.directive(SelectedStepDirective))).toBeTruthy();
53+
expect(wizardTestFixture.debugElement.queryAll(By.directive(SelectedStepDirective)).length).toBe(1);
5354
});
5455

5556
it('should set optional correctly', () => {
5657
expect(wizardState.defaultStepIndex).toBe(1);
5758
expect(wizardState.currentStepIndex).toBe(1);
5859
});
5960

60-
it('should reset correctly', fakeAsync(() => {
61+
it('should reset correctly to the default selected step', fakeAsync(() => {
6162
navigationMode.goToStep(0);
6263
tick();
6364
wizardTestFixture.detectChanges();

src/directives/selected-step.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Directive, Host, OnInit} from '@angular/core';
22
import {WizardStep} from '../util/wizard-step.interface';
33

44
/**
5-
* The `selected` directive can be used on a [[WizardStep]] to set it as selected after the wizard initialisation or a reset.
5+
* The `selectedStep` directive can be used on a [[WizardStep]] to set it as selected after the wizard initialisation or a reset.
66
*
77
* ### Syntax
88
*
@@ -15,7 +15,7 @@ import {WizardStep} from '../util/wizard-step.interface';
1515
* @author Marc Arndt
1616
*/
1717
@Directive({
18-
selector: '[selected], [selectedStep]'
18+
selector: '[selectedStep]'
1919
})
2020
export class SelectedStepDirective implements OnInit {
2121
/**

0 commit comments

Comments
 (0)