1
0

JQuery-Tests.st 714 B

12345678910111213141516171819202122232425262728293031323334
  1. TestCase subclass: #JQueryTest
  2. instanceVariableNames: 'document'
  3. category: 'JQuery-Tests'!
  4. !JQueryTest methodsFor: 'running'!
  5. setUp
  6. document := '<div class="person">
  7. <ul>
  8. <li class="firstname">James</li>
  9. <li class="lastname">Bond</li>
  10. </ul>
  11. </div>'.
  12. ! !
  13. !JQueryTest methodsFor: 'tests'!
  14. testFind
  15. self
  16. assert: 'James'
  17. equals: (document asJQuery find: 'li.firstname') html.
  18. !
  19. testEach
  20. |classes|
  21. classes := Array new.
  22. (document asJQuery find: 'li') each: [:index :element|
  23. classes add: ((JQuery fromElement:element) attr: 'class')].
  24. self
  25. assert: #('firstname' 'lastname') printString
  26. equals: classes printString
  27. ! !