From afeae66baf6bc1eaa5ad09b7150454d035bae8f7 Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Fri, 23 Jun 2017 16:07:18 -0400 Subject: [PATCH] tests for useViewBoxResizing for #1312 --- spec/base-mixin-spec.js | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spec/base-mixin-spec.js b/spec/base-mixin-spec.js index 721154c17..baa4bc5a3 100644 --- a/spec/base-mixin-spec.js +++ b/spec/base-mixin-spec.js @@ -471,6 +471,48 @@ describe('dc.baseMixin', function () { }); }); + describe('viewbox resizing strategy', function () { + beforeEach(function () { + chart + .width(600) + .height(400) + .resetSvg(); + }); + it('useViewBoxResizing defaults false', function () { + expect(chart.useViewBoxResizing()).toBeFalsy(); + }); + + it('svg has no viewbox when useViewBoxResizing is false', function () { + expect(chart.svg().attr('viewBox')).toBeNull(); + }); + + it('svg has width, height when useViewBoxResizing is false', function () { + expect(chart.svg().attr('width')).toBe('600'); + expect(chart.svg().attr('height')).toBe('400'); + }); + + describe('with viewbox enabled', function () { + beforeEach(function () { + chart + .useViewBoxResizing(true) + .resetSvg(); + }); + + it('has useViewBoxResizing set', function () { + expect(chart.useViewBoxResizing()).toBeTruthy(); + }); + + it('svg has viewbox encoding width and height', function () { + expect(chart.svg().attr('viewBox')).toEqual('0 0 600 400'); + }); + + it('svg does not have width, height attributes', function () { + expect(chart.svg().attr('width')).toBeNull(); + expect(chart.svg().attr('height')).toBeNull(); + }); + }); + }); + describe('filter handling', function () { var filter, notFilter; beforeEach(function () {