aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec/gradient.js
blob: f07a7e813267feb4bba357b7a210803633dbdf29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
describe('Gradient', function() {
  var rect = draw.rect(100,100)
    , gradient = draw.gradient('linear', function(stop) {
      stop.at({ offset: 0, color: '#333', opacity: 1 })
      stop.at({ offset: 100, color: '#fff', opacity: 1 })
    })
  
  it('should be an instance of SVG.Gradient', function() {
    expect(gradient instanceof SVG.Gradient).toBe(true)
  })
  
  describe('fill()', function() {
    it('should return the id of the gradient wrapped in url()', function() {
      expect(gradient.fill()).toBe('url(#' + gradient.attr('id') + ')')
    })
    it('should be called when instance is passed as an attribute value', function() {
      rect.attr('fill', gradient)
      expect(rect.attr('fill')).toBe('url(#' + gradient.attr('id') + ')')
    })
  })
  
})