class_spec.js 875 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var _ = require('../../../../src/util')
  2. var def = require('../../../../src/directives/class')
  3. if (_.inBrowser) {
  4. describe('v-class', function () {
  5. var el
  6. beforeEach(function () {
  7. el = document.createElement('div')
  8. })
  9. it('with className', function () {
  10. el.className = 'haha'
  11. var dir = {
  12. el: el,
  13. arg: 'test',
  14. update: def
  15. }
  16. dir.update(true)
  17. expect(el.className).toBe('haha test')
  18. dir.update(false)
  19. expect(el.className).toBe('haha')
  20. })
  21. it('without className', function () {
  22. el.className = 'haha'
  23. var dir = {
  24. el: el,
  25. update: def
  26. }
  27. dir.update('test')
  28. expect(el.className).toBe('haha test')
  29. dir.update('what')
  30. expect(el.className).toBe('haha what')
  31. dir.update()
  32. expect(el.className).toBe('haha')
  33. })
  34. })
  35. }