版博士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.empty.test.js 2.2 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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('$.empty: simple code', () => {
  7. expect(()=>{
  8. const G = $('var a = 1;');
  9. G.empty();
  10. }).not.toThrow();
  11. })
  12. test('$.empty: array', () => {
  13. const G = $('var a = 1;');
  14. const newG = G.empty();
  15. expect(newG.generate() == '');
  16. })
  17. test('$.empty: simple1 code', () => {
  18. const G = $(jc1);
  19. const newG = G.empty();
  20. expect(newG.generate() == '');
  21. })
  22. test('$.empty: simple2 code', () => {
  23. const G = $(jc2);
  24. const newG = G.empty();
  25. expect(newG.generate() == '');
  26. })
  27. test('$.empty: simple2 code result should be ok', () => {
  28. const G = $(jc2).find('View.extend($_$)');
  29. const newG = G.empty();
  30. expect(newG.generate() == '');
  31. })
  32. test('$.empty: array should be empty', () => {
  33. const G = $('var a = 1;');
  34. const newG = G.empty();
  35. const { value } = newG.node;
  36. expect(value).not.toBeTruthy();
  37. })
  38. test('$.empty: simple1 html code', () => {
  39. expect(() => {
  40. const G = $(hc1, config.html);
  41. G.empty();
  42. }).not.toThrow();
  43. })
  44. test('$.empty: simple1 html code', () => {
  45. const G = $(hc1, config.html);
  46. const newG = G.empty();
  47. expect(newG.generate() == '');
  48. })
  49. test('$.empty: simple1 html code', () => {
  50. const G = $(hc1, config.html);
  51. const newG = G.find('<span>$_$</span>').empty();
  52. expect(newG.generate() == '');
  53. })
  54. test('$.empty: simple1 html code', () => {
  55. const G = $(`
  56. <view class="abc">
  57. <view> {{ message }} </view>
  58. <view> {{ message }} </view>
  59. <view> {{ message }} </view>
  60. <view> {{ message }} </view>
  61. </view>
  62. `, config.html);
  63. const newG = G.find('<view class="abc"></view>').empty();
  64. expect(newG.generate().match('message')).not.toBeTruthy();
  65. })
  66. test('$.empty: simple1 html code', () => {
  67. const G = $(`
  68. <view class="abc">
  69. <view> {{ message }} </view>
  70. <view> {{ message }} </view>
  71. <view> {{ message }} </view>
  72. <view> {{ message }} </view>
  73. </view>
  74. `, config.html);
  75. const newG = G.empty();
  76. expect(newG.generate() == '').toBeTruthy();
  77. })