版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

G.eq.test.js 1.5 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const $ = require('../index');
  2. const config = require('./config');
  3. const jc1 = require('./code/simple1');
  4. const jc2 = require('./code/simple2');
  5. const hc1 = require('./code/simple1.html');
  6. test('$.eq: simple code', () => {
  7. expect(() => {
  8. const G = $('var a = 1;');
  9. G.eq(0);
  10. }).not.toThrow();
  11. })
  12. test('$.eq: simple code result should be ok', () => {
  13. const G = $('var a = 1;');
  14. const node = G.eq(0);
  15. expect(node.generate()).toBe('var a = 1;');
  16. })
  17. test('$.eq: js code index overflow should not show error', () => {
  18. expect(() => {
  19. const G = $('var a = 1;');
  20. G.eq(100);
  21. }).not.toThrow();
  22. })
  23. test('$.eq: simple1 code result should be ok', () => {
  24. const G = $(jc1).find('var a = 1');
  25. const node = G.eq(0);
  26. expect(node.generate()).toBe('var a = 1;');
  27. })
  28. test('$.eq: simple1 html code', () => {
  29. expect(() => {
  30. const G = $(hc1, config.html);
  31. G.eq(1);
  32. }).not.toThrow();
  33. })
  34. test('$.eq: simple html code should be ok', () => {
  35. const G = $('<div></div>', config.html);
  36. const node = G.eq(0);
  37. expect(node.generate()).toBe('<div></div>');
  38. })
  39. test('$.eq: simple1 html code should be ok', () => {
  40. const G = $(hc1, config.html).find('<span>$_$</span>');
  41. const node = G.eq(0);
  42. expect(node.generate()).toBe('<span>test</span>');
  43. })
  44. test('$.eq: html code index overflow should not show error', () => {
  45. expect(() => {
  46. const G = $('<div></div>', config.html);
  47. G.eq(100);
  48. }).not.toThrow();
  49. })