adopted-ember-addons / adopted-ember-addons/ember-pikaday

Testing multiple date pickers

Aperta
#231 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
156
Fork
164
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

So I ran into a bit of a gotcha today with testing multiple date-pickers. This is probably because I've been doing something wrong!

Basically my tests for a component with multiple date pickers didn't close the date picker between selecting dates on two different inputs. This worked fine in Ember 3.8, but when upgrading to Ember 3.12 it doesn't. The solution was to close the date picker after choosing the first date and before selecting the second date.

As I say, not really a bug with this addon because it makes sense that actually I should have closed the datepicker originally. But it made me think of two things...

Firstly, maybe the readme should be clear about this? I.e. say that the datepicker needs to be closed if testing with multiple dates? If so, I can do a PR to add that.

Secondly, a lot of my tests now look like this:

```js
await click('input[name="start"]');
await Pikaday.selectDate(new Date(2019, 5, 1));
await closePikaday();

await click('input[name="expiry"]');
await Pikaday.selectDate(new Date(2019, 9, 1));
await closePikaday();
```

Is it worth having a test helper that does these three steps in one helper? Say it was called `fillInDate` (not bothered about the name), then the above code could be re-written to:

```js
await fillInDate('input[name="start"]', new Date(2019, 5, 1));
await fillInDate('input[name="expiry"]', new Date(2019, 5, 1));
```

Just an idea, I'm happy to do a PR if you think something like that would be worth adding.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.