ni-kismet / webcharts-development-settings

Common settings and tools for all WebCharts repos
1 stars 4 forks source link

Adopt the Fluent Interface for simulate #8

Open cristiingineru opened 6 years ago

cristiingineru commented 6 years ago

https://en.wikipedia.org/wiki/Fluent_interface#JavaScript

This change should allow writing tests like this:

simulate
  .mouseUp(eventHolder, x + 20, y + 30);
  .tick(50)
  .dblclick(eventHolder, x + 20, y + 30)
  .tick(50);

instead of:

simulate.mouseUp(eventHolder, x + 20, y + 30);
jasmine.clock().tick(50);

simulate.dblclick(eventHolder, x + 20, y + 30);
jasmine.clock().tick(50);

It's a pity jasmine will be read from the global namespace, but I think overall the code will be more readable.