版博士V2.0程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

57 řádky
1.8 KiB

  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('$._index: simple code should not throw error', () => {
  7. expect(()=>{
  8. const G = $('var a = 1;');
  9. const index = G._index;
  10. }).not.toThrow();
  11. })
  12. test('$._index: code1 should not throw error', () => {
  13. expect(()=>{
  14. const G = $(jc1);
  15. const index = G._index;
  16. }).not.toThrow();
  17. })
  18. test('$._index: code2 should not throw error', () => {
  19. expect(()=>{
  20. const G = $(jc2);
  21. const index = G._index;
  22. }).not.toThrow();
  23. })
  24. test('$._index: index should be a number', () => {
  25. const G = $('var a = 1;');
  26. const index = G._index;
  27. // comment: expect(index).toBeGreaterThan(-1); // 目前只实现了html的_index js的还没有
  28. })
  29. test('$._index: simple html code should not throw error', () => {
  30. expect(() => {
  31. const G = $(hc1, config.html);
  32. const index = G._index;
  33. }).not.toThrow();
  34. })
  35. test('$._index: simple html code, index should be a number', () => {
  36. const G = $('<div></div>', config.html);
  37. const index = G._index;
  38. expect(index).toBeGreaterThan(-1);
  39. })
  40. // test('$._index: simple1 code ,index should not be -1', () => {
  41. // const G = $(jc2).find(`this.observeLocation(['start', 'end']);`);
  42. // const index = G._index;
  43. // expect(index).toBeGreaterThan(-1);
  44. // })
  45. test('$._index: html code, index should be a number', () => {
  46. const G = $(hc1, config.html);
  47. const index = G._index;
  48. expect(index).toBeGreaterThan(-1);
  49. })
  50. test('$._index: html code, index should be a number', () => {
  51. const G = $(hc1, config.html);
  52. const index = G.find('<title>title</title>').parent()._index;
  53. expect(index).toBeGreaterThan(-1);
  54. })