style_spec.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var _ = require('../../../../src/util')
  2. var def = require('../../../../src/directives/style')
  3. if (_.inBrowser) {
  4. describe('v-style', function () {
  5. var el, dir
  6. beforeEach(function () {
  7. el = document.createElement('div')
  8. dir = { el: el }
  9. _.extend(dir, def)
  10. })
  11. it('normal with arg', function () {
  12. dir.arg = 'color'
  13. dir.bind()
  14. dir.update('red')
  15. expect(el.style.color).toBe('red')
  16. })
  17. it('normal no arg', function () {
  18. dir.bind()
  19. dir.update('color:red;')
  20. expect(el.style.cssText.replace(/\s/g, '')).toBe('color:red;')
  21. })
  22. it('!important', function () {
  23. dir.arg = 'color'
  24. dir.bind()
  25. dir.update('red !important;')
  26. expect(el.style.getPropertyPriority('color')).toBe('important')
  27. })
  28. it('auto prefixing', function () {
  29. var spy = el.style.setProperty = jasmine.createSpy()
  30. dir.arg = '$transform'
  31. dir.bind()
  32. var val = 'scale(0.5)'
  33. dir.update(val)
  34. expect(spy).toHaveBeenCalledWith('transform', val, '')
  35. expect(spy).toHaveBeenCalledWith('-ms-transform', val, '')
  36. expect(spy).toHaveBeenCalledWith('-moz-transform', val, '')
  37. expect(spy).toHaveBeenCalledWith('-webkit-transform', val, '')
  38. })
  39. })
  40. }