integer_test.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var assert = require('assert');
  2. var value = '';
  3. Feature('integer');
  4. Scenario('should have correct initial value', async (I) => {
  5. I.amOnPage('integer.html');
  6. I.click('.get-value');
  7. value = await I.grabValueFrom('.value');
  8. assert.equal(value, '{"integer":5,"integer_number":5,"integer_range":5}');
  9. });
  10. Scenario('should respect step by incrementing and decrementing the value of a number', async (I) => {
  11. I.amOnPage('integer.html');
  12. I.seeElement('[data-schemapath="root.integer"] input');
  13. I.executeScript(function() {
  14. var range = document.querySelector('[data-schemapath="root.integer_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, '{"integer":5,"integer_number":10,"integer_range":5}');
  25. I.executeScript(function() {
  26. var range = document.querySelector('[data-schemapath="root.integer_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, '{"integer":5,"integer_number":5,"integer_range":5}');
  37. });
  38. Scenario('should respect step by incrementing and decrementing the value of a range', async (I) => {
  39. I.amOnPage('integer.html');
  40. I.seeElement('[data-schemapath="root.integer_range"] input');
  41. I.executeScript(function() {
  42. var range = document.querySelector('[data-schemapath="root.integer_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, '{"integer":5,"integer_number":5,"integer_range":10}');
  53. I.executeScript(function() {
  54. var range = document.querySelector('[data-schemapath="root.integer_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, '{"integer":5,"integer_number":5,"integer_range":5}');
  65. });
  66. Scenario('should be readonly if specified and not disabled', async (I) => {
  67. I.amOnPage('read-only.html');
  68. I.seeElement('[name="root[integer]"]');
  69. value = await I.grabAttributeFrom('[name="root[integer]"]', 'readonly');
  70. assert.equal(value, 'true');
  71. });