number_test.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. var assert = require('assert');
  2. var value = '';
  3. Feature('number');
  4. Scenario('should have correct initial value', async (I) => {
  5. I.amOnPage('number.html');
  6. I.click('.get-value');
  7. value = await I.grabValueFrom('.value');
  8. assert.equal(value, '{"number":5.75,"number_number":5.75,"number_range":5.75}');
  9. });
  10. Scenario('should respect step by incrementing and decrementing the value of a number', async (I) => {
  11. I.amOnPage('number.html');
  12. I.seeElement('[data-schemapath="root.number_number"] input');
  13. I.executeScript(function() {
  14. var range = document.querySelector('[data-schemapath="root.number_number"] input');
  15. range.stepUp();
  16. var event = new Event('change', {
  17. 'bubbles': true,
  18. 'cancelable': true
  19. });
  20. range.dispatchEvent(event);
  21. });
  22. I.click('.get-value');
  23. value = await I.grabValueFrom('.value');
  24. assert.equal(value, '{"number":5.75,"number_number":6,"number_range":5.75}');
  25. I.executeScript(function() {
  26. var range = document.querySelector('[data-schemapath="root.number_number"] input');
  27. range.stepDown();
  28. var event = new Event('change', {
  29. 'bubbles': true,
  30. 'cancelable': true
  31. });
  32. range.dispatchEvent(event);
  33. });
  34. I.click('.get-value');
  35. value = await I.grabValueFrom('.value');
  36. assert.equal(value, '{"number":5.75,"number_number":5.75,"number_range":5.75}');
  37. });
  38. Scenario('should respect step by incrementing and decrementing the value of a range', async (I) => {
  39. I.amOnPage('number.html');
  40. I.seeElement('[data-schemapath="root.number_range"] input');
  41. I.executeScript(function() {
  42. var range = document.querySelector('[data-schemapath="root.number_range"] input');
  43. range.stepUp();
  44. var event = new Event('change', {
  45. 'bubbles': true,
  46. 'cancelable': true
  47. });
  48. range.dispatchEvent(event);
  49. });
  50. I.click('.get-value');
  51. value = await I.grabValueFrom('.value');
  52. assert.equal(value, '{"number":5.75,"number_number":5.75,"number_range":6}');
  53. I.executeScript(function() {
  54. var range = document.querySelector('[data-schemapath="root.number_range"] input');
  55. range.stepDown();
  56. var event = new Event('change', {
  57. 'bubbles': true,
  58. 'cancelable': true
  59. });
  60. range.dispatchEvent(event);
  61. });
  62. I.click('.get-value');
  63. value = await I.grabValueFrom('.value');
  64. assert.equal(value, '{"number":5.75,"number_number":5.75,"number_range":5.75}');
  65. });
  66. Scenario('should be readonly if specified and not disabled', async (I) => {
  67. I.amOnPage('read-only.html');
  68. I.seeElement('[name="root[number]"]');
  69. value = await I.grabAttributeFrom('[name="root[number]"]', 'readonly');
  70. assert.equal(value, 'true');
  71. });