describe('Circles', function() { it("is defined", function() { expect(typeof Circles).toEqual('function'); }); describe('#create', function() { var element; beforeEach(function() { element = document.createElement('div'); element.id = 'circles-1'; document.querySelector('body').appendChild(element); }); afterEach(function() { element.parentNode.removeChild(element); }); it("returns a Circles instance", function() { var circles = Circles.create({}); expect(circles instanceof Circles).toBeTruthy(); }); it("generates the SVG without animation", function() { Circles.create({ id: element.id, percentage: 40, radius: 60, duration: null }); var expected = '
40
'; expect(element.innerHTML).toEqual(expected); }); it("generates the SVG with animation", function() { Circles.create({ id: element.id, percentage: 40, radius: 60 }); var expected = '
0
'; expect(element.innerHTML).toEqual(expected); }); it("adds the supplied text", function() { Circles.create({ id: element.id, percentage: 40, radius: 60, text: '%' }); expect(element.innerHTML.indexOf('%') > 0).toBeTruthy(); }); }); });