index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import test from 'ava';
  2. import Hydrawise from '../lib/hydrawise';
  3. const hydrawise = new Hydrawise('53DC-7E24-07E8-CD7D');
  4. test('Customer Details', t => {
  5. return hydrawise.customerdetails().then(data => {
  6. if (data.error_msg) {
  7. t.fail(`Error: ${data.error_msg}`);
  8. }
  9. t.pass();
  10. });
  11. });
  12. test('Status Schedule', t => {
  13. return hydrawise.statusschedule().then(data => {
  14. if (data.error_msg) {
  15. t.fail(`Error: ${data.error_msg}`);
  16. }
  17. t.pass();
  18. });
  19. });
  20. test('Status Schedule All', t => {
  21. return hydrawise.statusschedule('hydrawise_all').then(data => {
  22. if (data.error_msg) {
  23. t.fail(`Error: ${data.error_msg}`);
  24. }
  25. t.pass();
  26. });
  27. });
  28. test('Set Controller', t => {
  29. return hydrawise.setcontroller('11774').then(() => {
  30. t.pass();
  31. });
  32. });
  33. test('Stop Zones', t => {
  34. return hydrawise.setzone('stopall').then(data => {
  35. if (data.message_type === 'error') {
  36. t.fail(`Error: ${data.message}`);
  37. }
  38. t.pass();
  39. });
  40. });
  41. test('Run All Zones', t => {
  42. return hydrawise.setzone('runall', {period_id: '999', custom: '60'}).then(data => {
  43. if (data.message_type === 'error') {
  44. t.fail(`Error: ${data.message}`);
  45. }
  46. t.pass();
  47. });
  48. });