Skip to content

Commit c2bd67f

Browse files
fix test for formatting axis
1 parent c9b613c commit c2bd67f

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

packages/devextreme/testing/tests/DevExpress.viz.core/axisFormatting.tests.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,36 @@ const environment = {
141141
}
142142
};
143143

144+
const saveGlobalFormats = () => {
145+
const globalConfig = config();
146+
return {
147+
dateFormat: globalConfig.dateFormat,
148+
timeFormat: globalConfig.timeFormat,
149+
dateTimeFormat: globalConfig.dateTimeFormat,
150+
numberFormat: globalConfig.numberFormat,
151+
dateTimeFormatPresets: globalConfig.dateTimeFormatPresets,
152+
};
153+
};
154+
155+
const restoreGlobalFormats = (saved) => {
156+
const globalConfig = config();
157+
Object.keys(saved).forEach((key) => {
158+
const value = saved[key];
159+
if(value === undefined) {
160+
delete globalConfig[key];
161+
} else {
162+
globalConfig[key] = value;
163+
}
164+
});
165+
};
166+
144167
const globalConfigEnvironment = $.extend({}, environment, {
145168
beforeEach: function() {
146169
environment.beforeEach.call(this);
147-
this.savedConfig = { ...config() };
170+
this.savedConfig = saveGlobalFormats();
148171
},
149172
afterEach: function() {
150-
config(this.savedConfig);
173+
restoreGlobalFormats(this.savedConfig);
151174
environment.afterEach.call(this);
152175
}
153176
});
@@ -157,24 +180,28 @@ QUnit.module('Global formatting config. Axis labels', globalConfigEnvironment);
157180
QUnit.test('value axis labels use global numberFormat when label.format is not set', function(assert) {
158181
config({
159182
...config(),
160-
numberFormat: { type: 'fixedPoint', precision: 2 }
183+
numberFormat: {
184+
default: { type: 'fixedPoint', precision: 2 }
185+
}
161186
});
162187

163-
this.testTickLabelFormat(assert, [1500], 100, ['1500.00']);
188+
this.testTickLabelFormat(assert, [1500], 100, ['1,500.00']);
164189
});
165190

166191
QUnit.test('local axis label.format keeps priority over global numberFormat', function(assert) {
167192
config({
168193
...config(),
169-
numberFormat: { type: 'fixedPoint', precision: 2 }
194+
numberFormat: {
195+
default: { type: 'fixedPoint', precision: 2 }
196+
}
170197
});
171198

172199
this.testFormat(assert, {
173200
label: {
174201
visible: true,
175202
format: 'thousands'
176203
}
177-
}, [1500], 100, ['1.5K']);
204+
}, [1500], 100, ['2K']);
178205
});
179206

180207
QUnit.test('datetime axis labels use global dateTimeFormat when label.format is not set', function(assert) {

0 commit comments

Comments
 (0)