Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Implement Datepicker #183

Merged
merged 10 commits into from
Sep 28, 2017
Merged

Implement Datepicker #183

merged 10 commits into from
Sep 28, 2017

Conversation

jfcere
Copy link
Contributor

@jfcere jfcere commented Aug 13, 2017

Datepicker requested feature #170

✔️ Ready to be reviewed/merged

  • Initial draft for datepicker component
  • Update README.md for available components
  • Add demo page
  • Add form-validation example for datepicker
  • Bullet proof datepicker
  • Implement unit/view tests
  • Materialize 0.100.2 / JQuery 3.2.12 merged into PR

@scote scote self-assigned this Aug 29, 2017
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DatepickerComponent } from './datepicker.component';

Copy link
Contributor

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.

Copy link
Contributor Author

@jfcere jfcere Sep 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

});
}));

describe('input-field', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datepicker-container

Copy link
Contributor Author

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');
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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>(`
Copy link
Contributor

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.

Copy link
Contributor Author

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">
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be mockNgcontrol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

@jfcere jfcere temporarily deployed to ng2-materialize-pr-183 September 2, 2017 16:57 Inactive
@jfcere jfcere temporarily deployed to ng2-materialize-pr-183 September 2, 2017 17:00 Inactive
@jfcere jfcere temporarily deployed to ng2-materialize-pr-183 September 11, 2017 16:21 Inactive
@jfcere jfcere added this to the 1.6.0 milestone Sep 22, 2017
@scote scote merged commit 569f985 into master Sep 28, 2017
@scote scote deleted the date-picker branch September 28, 2017 12:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants