Skip to content

Commit

Permalink
refactor: Disable more codes related to calendar swiping feature
Browse files Browse the repository at this point in the history
  • Loading branch information
motss committed Oct 27, 2019
1 parent fef93a5 commit 909c654
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 189 deletions.
6 changes: 3 additions & 3 deletions src/app-datepicker-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ export class AppDatepickerDialog extends LitElement {
@property({ type: String })
public weekLabel: string = '';

@property({ type: Number })
public dragRatio: number = .15;
// @property({ type: Number })
// public dragRatio: number = .15;

@property({ type: String })
public dismissLabel: string = 'cancel';
Expand Down Expand Up @@ -260,6 +260,7 @@ export class AppDatepickerDialog extends LitElement {
}

protected render() {
// .dragRatio="${this.dragRatio}"
return html`
<div class="scrim" @click="${this.close}"></div>
Expand All @@ -274,7 +275,6 @@ export class AppDatepickerDialog extends LitElement {
.disabledDates="${this.disabledDates}"
.landscape="${this.landscape}"
.locale="${this.locale}"
.dragRatio="${this.dragRatio}"
.startView="${this.startView}"
.value="${this.value}"
.weekLabel="${this.weekLabel}"
Expand Down
6 changes: 3 additions & 3 deletions src/app-datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class AppDatepicker extends LitElement {
position: relative;
width: calc(100% * 3);
padding: 0 0 16px;
transform: translate3d(-300px, 0, 0);
transform: translate3d(-33%, 0, 0);
/* will-change: transform; */
/**
* NOTE: Required for Pointer Events API to work on touch devices.
Expand Down Expand Up @@ -467,8 +467,8 @@ export class AppDatepicker extends LitElement {
@property({ type: String })
public weekLabel: string = '';

@property({ type: Number })
public dragRatio: number = .15;
// @property({ type: Number })
// public dragRatio: number = .15;

@property({ type: Date })
private _selectedDate: Date;
Expand Down
10 changes: 5 additions & 5 deletions src/demo/properties.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ const properties: PropertyValue[] = [
value: 'Wk',
type: 'string',
},
{
name: 'dragRatio',
value: .15,
type: 'number',
},
// {
// name: 'dragRatio',
// value: .15,
// type: 'number',
// },
];

const cssProperties: PropertyValue[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './a11y.spec.js';
import './attributes.spec.js';
import './custom-events.spec.js';
import './gestures.spec.js';
// import './gestures.spec.js';
import './initial-render.spec.js';
import './keyboards.spec.js';
import './properties.spec.js';
16 changes: 8 additions & 8 deletions src/test/app-datepicker-dialog/attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ describe(getTestName(name), () => {
strictEqual(t.elem.weekLabel, newVal, `datepicker's 'weekLabel' not updated`);
});

it(`renders with correct 'dragRatio'`, async () => {
const newVal = .25;
el.setAttribute('dragratio', `${newVal}`);
await forceUpdate(el);
// it(`renders with correct 'dragRatio'`, async () => {
// const newVal = .25;
// el.setAttribute('dragratio', `${newVal}`);
// await forceUpdate(el);

strictEqual(el.dragRatio, newVal, `'dragRatio' not updated`);
strictEqual(el.getAttribute('dragratio'), `${newVal}`, `'dragratio' attribute not set`);
// strictEqual(el.dragRatio, newVal, `'dragRatio' not updated`);
// strictEqual(el.getAttribute('dragratio'), `${newVal}`, `'dragratio' attribute not set`);

strictEqual(t.elem.dragRatio, newVal, `datepicker's 'dragRatio' not updated`);
});
// strictEqual(t.elem.dragRatio, newVal, `datepicker's 'dragRatio' not updated`);
// });

});
});
3 changes: 2 additions & 1 deletion src/test/app-datepicker-dialog/custom-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ describe(getTestName(name), () => {
Array.isArray(allCalendarTables) && allCalendarTables.length > 0,
`No calendar table found`);

const focusedCalendarTableEl = allCalendarTables[1];
// const focusedCalendarTableEl = allCalendarTables[1];
const focusedCalendarTableEl = allCalendarTables[0];
isNotNull(focusedCalendarTableEl, `Focused calendar table is null`);

for (let i = 0; i < 2; i += 1) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/app-datepicker-dialog/initial-render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {
strictEqual,
isNotNull,
isAtLeast,
isAtMost,
// isAtMost,
} = chai.assert;
const name = AppDatepickerDialog.is;

Expand Down Expand Up @@ -122,12 +122,12 @@ describe(getTestName(name), () => {
it('renders initial content (calendar)', () => {
const elHTML = getShadowInnerHTML(el);
const calendarView = t.getDatepickerBodyCalendarView();
const allCalendarTables = t.getAllCalendarTables();
// const allCalendarTables = t.getAllCalendarTables();

isString(elHTML, 'HTML content is not string');
isNotNull(calendarView, 'Calendar view not found');
isAtLeast(allCalendarTables.length, 1, 'Calender tables not found');
isAtMost(allCalendarTables.length, 3, 'Calender tables not found');
// isAtLeast(allCalendarTables.length, 1, 'Calender tables not found');
// isAtMost(allCalendarTables.length, 3, 'Calender tables not found');
});

it(`renders today's formatted date`, () => {
Expand Down
16 changes: 8 additions & 8 deletions src/test/app-datepicker-dialog/properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ describe(getTestName(name), () => {
strictEqual(t.elem.weekLabel, newVal, `datepicker's 'weekLabel' not updated`);
});

it(`renders with correct 'dragRatio'`, async () => {
const newVal = .25;
el.dragRatio = newVal;
await forceUpdate(el);

strictEqual(el.dragRatio, newVal, `'dragRatio' not updated`);
strictEqual(t.elem.dragRatio, newVal, `datepicker's 'dragRatio' not updated`);
});
// it(`renders with correct 'dragRatio'`, async () => {
// const newVal = .25;
// el.dragRatio = newVal;
// await forceUpdate(el);

// strictEqual(el.dragRatio, newVal, `'dragRatio' not updated`);
// strictEqual(t.elem.dragRatio, newVal, `datepicker's 'dragRatio' not updated`);
// });

});
});
2 changes: 1 addition & 1 deletion src/test/app-datepicker/app-datepicker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './a11y.spec.js';
import './attributes.spec.js';
import './custom-events.spec.js';
import './gestures.spec.js';
// import './gestures.spec.js';
import './initial-render.spec.js';
import './keyboards.spec.js';
import './properties.spec.js';
Expand Down
152 changes: 76 additions & 76 deletions src/test/app-datepicker/attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
defaultLocale,
} from '../test-config.js';
import {
dragTo,
// dragTo,
forceUpdate,
getComputedStylePropertyValue,
getShadowInnerHTML,
getTestName,
OptionsDragTo,
// OptionsDragTo,
queryInit,
setupDragPoint,
// setupDragPoint,
} from '../test-helpers.js';

const {
Expand Down Expand Up @@ -526,79 +526,79 @@ describe(getTestName(name), () => {
strictEqual(getShadowInnerHTML(weekLabelEl), 'Wk', `Week label not reset`);
});

it(`renders with optional 'dragRatio'`, async () => {
strictEqual(el.dragRatio, .15, `Initial 'dragRatio' not matched`);
isTrue(!el.hasAttribute('dragratio'), `Initial 'dragratio' attribute set`);

el.min = date13;
el.value = date15;
el.setAttribute('dragratio', '.5');
await forceUpdate(el);

strictEqual(el.dragRatio, .5, `'dragRatio' not matched`);
strictEqual(el.getAttribute('dragratio'), '.5', `'dragratio' attribute not matched`);

const btnYearSelectorEl = t.getBtnYearSelector();
const btnCalendarSelectorEl = t.getBtnCalendarSelector();
const calendarViewFullCalendarEl = t.getCalendarViewFullCalendar();

strictEqual(
getShadowInnerHTML(btnYearSelectorEl),
'2020',
`First year selector text not matched`);
strictEqual(
getShadowInnerHTML(btnCalendarSelectorEl),
'Wed, Jan 15',
`First calendar selector text not matched`);

const calendarLabel = getShadowInnerHTML(t.getCalendarLabel());
/** NOTE: [(Safari 9), (Win10 IE 11), (Others)] */
isTrue(
['Jan 2020', 'January, 2020', 'January 2020'].some(n => calendarLabel === n),
`First calendar label not matched (${calendarLabel})`);

const oldStartingPoint = setupDragPoint('left', el);
const oldDragOptions: OptionsDragTo = { ...oldStartingPoint, dx: -50 };
await dragTo(calendarViewFullCalendarEl, oldDragOptions);
await t.waitForDragAnimationFinished();

strictEqual(
getShadowInnerHTML(btnYearSelectorEl),
'2020',
`Year selector text should not change`);
strictEqual(
getShadowInnerHTML(btnCalendarSelectorEl),
'Wed, Jan 15',
`Calendar selector text should not change`);

const oldCalendarLabel = getShadowInnerHTML(t.getCalendarLabel());
/** NOTE: [(Safari 9), (Win10 IE 11), (Others)] */
isTrue(
['Jan 2020', 'January, 2020', 'January 2020'].some(n => oldCalendarLabel === n),
`Calendar label should not update (${oldCalendarLabel})`);

const startingPoint = setupDragPoint('left', el);
const dragOptions: OptionsDragTo = { ...startingPoint, dx: -160 };
await dragTo(calendarViewFullCalendarEl, dragOptions);
await t.waitForDragAnimationFinished();

strictEqual(
getShadowInnerHTML(btnYearSelectorEl),
'2020',
`Year selector text should not change`);
strictEqual(
getShadowInnerHTML(btnCalendarSelectorEl),
'Wed, Jan 15',
`Calendar selector text should not change`);

const newCalendarLabel = getShadowInnerHTML(t.getCalendarLabel());
/** NOTE: [(Safari 9), (Win10 IE 11), (Others)] */
isTrue(
['Feb 2020', 'February, 2020', 'February 2020'].some(n => newCalendarLabel === n),
`New calendar label not updated (${newCalendarLabel})`);
});

it(`renders with different 'firstDayofWeek' and 'disabledDays'`, async () => {
// it(`renders with optional 'dragRatio'`, async () => {
// strictEqual(el.dragRatio, .15, `Initial 'dragRatio' not matched`);
// isTrue(!el.hasAttribute('dragratio'), `Initial 'dragratio' attribute set`);

// el.min = date13;
// el.value = date15;
// el.setAttribute('dragratio', '.5');
// await forceUpdate(el);

// strictEqual(el.dragRatio, .5, `'dragRatio' not matched`);
// strictEqual(el.getAttribute('dragratio'), '.5', `'dragratio' attribute not matched`);

// const btnYearSelectorEl = t.getBtnYearSelector();
// const btnCalendarSelectorEl = t.getBtnCalendarSelector();
// const calendarViewFullCalendarEl = t.getCalendarViewFullCalendar();

// strictEqual(
// getShadowInnerHTML(btnYearSelectorEl),
// '2020',
// `First year selector text not matched`);
// strictEqual(
// getShadowInnerHTML(btnCalendarSelectorEl),
// 'Wed, Jan 15',
// `First calendar selector text not matched`);

// const calendarLabel = getShadowInnerHTML(t.getCalendarLabel());
// /** NOTE: [(Safari 9), (Win10 IE 11), (Others)] */
// isTrue(
// ['Jan 2020', 'January, 2020', 'January 2020'].some(n => calendarLabel === n),
// `First calendar label not matched (${calendarLabel})`);

// const oldStartingPoint = setupDragPoint('left', el);
// const oldDragOptions: OptionsDragTo = { ...oldStartingPoint, dx: -50 };
// await dragTo(calendarViewFullCalendarEl, oldDragOptions);
// await t.waitForDragAnimationFinished();

// strictEqual(
// getShadowInnerHTML(btnYearSelectorEl),
// '2020',
// `Year selector text should not change`);
// strictEqual(
// getShadowInnerHTML(btnCalendarSelectorEl),
// 'Wed, Jan 15',
// `Calendar selector text should not change`);

// const oldCalendarLabel = getShadowInnerHTML(t.getCalendarLabel());
// /** NOTE: [(Safari 9), (Win10 IE 11), (Others)] */
// isTrue(
// ['Jan 2020', 'January, 2020', 'January 2020'].some(n => oldCalendarLabel === n),
// `Calendar label should not update (${oldCalendarLabel})`);

// const startingPoint = setupDragPoint('left', el);
// const dragOptions: OptionsDragTo = { ...startingPoint, dx: -160 };
// await dragTo(calendarViewFullCalendarEl, dragOptions);
// await t.waitForDragAnimationFinished();

// strictEqual(
// getShadowInnerHTML(btnYearSelectorEl),
// '2020',
// `Year selector text should not change`);
// strictEqual(
// getShadowInnerHTML(btnCalendarSelectorEl),
// 'Wed, Jan 15',
// `Calendar selector text should not change`);

// const newCalendarLabel = getShadowInnerHTML(t.getCalendarLabel());
// /** NOTE: [(Safari 9), (Win10 IE 11), (Others)] */
// isTrue(
// ['Feb 2020', 'February, 2020', 'February 2020'].some(n => newCalendarLabel === n),
// `New calendar label not updated (${newCalendarLabel})`);
// });

it(`renders with different 'firstDayOfWeek' and 'disabledDays'`, async () => {
strictEqual(el.firstDayOfWeek, 0, `'firstDayOfWeek' not matched`);
strictEqual(el.disabledDays, '', `'disabledDays' not matched`);

Expand Down
3 changes: 2 additions & 1 deletion src/test/app-datepicker/custom-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ describe(getTestName(name), () => {
Array.isArray(allCalendarTables) && allCalendarTables.length > 0,
`No calendar table found`);

const focusedCalendarTableEl = allCalendarTables[1];
// const focusedCalendarTableEl = allCalendarTables[1];
const focusedCalendarTableEl = allCalendarTables[0];
isNotNull(focusedCalendarTableEl, `Focused calendar table is null`);

for (let i = 0; i < 2; i += 1) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/app-datepicker/initial-render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {
strictEqual,
isNotNull,
isAtLeast,
isAtMost,
// isAtMost,
} = chai.assert;
const name = AppDatepicker.is;

Expand Down Expand Up @@ -56,12 +56,12 @@ describe(getTestName(name), () => {
it('renders initial content (calendar)', () => {
const elHTML = getShadowInnerHTML(el);
const calendarView = t.getDatepickerBodyCalendarView();
const allCalendarTables = t.getAllCalendarTables();
// const allCalendarTables = t.getAllCalendarTables();

isString(elHTML, 'HTML content is not string');
isNotNull(calendarView, 'Calendar view not found');
isAtLeast(allCalendarTables.length, 1, 'Calender tables not found');
isAtMost(allCalendarTables.length, 3, 'Calender tables not found');
// isAtLeast(allCalendarTables.length, 1, 'Calender tables not found');
// isAtMost(allCalendarTables.length, 3, 'Calender tables not found');
});

it(`renders today's formatted date`, () => {
Expand Down
Loading

0 comments on commit 909c654

Please sign in to comment.