-
Notifications
You must be signed in to change notification settings - Fork 75
Conversation
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DatepickerComponent } from './datepicker.component'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be removed. Tests in demo app are not executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
}); | ||
})); | ||
|
||
describe('input-field', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datepicker-container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the same term used in mz-input-container
, mz-select-container
and mz-textarea-container
spec files which wrap the .input-field
class
} | ||
|
||
initElements() { | ||
this.inputContainerElement = $(this.elementRef.nativeElement).parent('.input-field'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use native querySelector instead of jQuery in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if I would use querySelector
other elements like inputElement
needs to be a JQuery object to use the datepicker intialization method ... in other words we cannot get rid of JQuery anyway until Materialize completely removes it
|
||
createLabelElement() { | ||
const labelElement = document.createElement('label'); | ||
labelElement.setAttribute('for', this.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try to create a datepicker without date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without date yes and if you meant without label ... the test you commented below covers it
|
||
it('should be empty when omitted', async(() => { | ||
|
||
buildComponent<any>(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can forget my previous comment about datepicker without label. This test is testing this use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright ... you know you can delete comments right? 😉
<mz-datepicker-container> | ||
<input mz-datepicker | ||
id="datepicker" | ||
[disabled]="true"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it use disabled
instead of [disabled]="true"
for this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added tests to validate both
}).then((fixture) => { | ||
component = fixture.componentInstance; | ||
nativeElement = fixture.nativeElement; | ||
fixture.detectChanges(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use autoDetectChanges()
function for your tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it but tests that uses tick()
to force setTimeout
executions do not work if I change it for autoDetectChanges()
... all the other tests only use one detectChanges()
so it wouldn't change anything
@@ -24,7 +26,7 @@ describe('MzInputDirective:unit', () => { | |||
|
|||
beforeEach(() => { | |||
renderer = TestBed.get(Renderer); | |||
directive = new MzInputDirective(null, mockNgModel, mockElementRef, renderer); | |||
directive = new MzInputDirective(mockNgModel, mockElementRef, renderer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be mockNgcontrol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
Datepicker requested feature #170
✔️ Ready to be reviewed/merged