Skip to content

Commit de26e72

Browse files
committed
Typo fixes, add couple of tests
1 parent c8d90d5 commit de26e72

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

src/core/core.datasetController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ export default class DatasetController {
860860
const options = this.getStyle(index, active);
861861
this._resolveAnimations(index, mode, active).update(element, {
862862
// When going from active to inactive, we need to update to the shared options.
863-
// This way the onche hovered element will end up with the same original shared options instance, after animation.
863+
// This way the once hovered element will end up with the same original shared options instance, after animation.
864864
options: (!active && this.getSharedOptions(options)) || options
865865
});
866866
}

test/specs/core.controller.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('Chart', function() {
130130
expect(options.font.size).toBe(defaults.font.size);
131131
expect(options.showLine).toBe(defaults.controllers.line.datasets.showLine);
132132
expect(options.spanGaps).toBe(true);
133-
// expect(options.hover.onHover).toBe(callback);
133+
expect(options.hover.onHover).toBe(callback);
134134
expect(options.hover.mode).toBe('test');
135135

136136
defaults.hover.onHover = null;

test/specs/helpers.options.tests.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('Chart.helpers.options', function() {
246246
});
247247
});
248248

249-
describe('_crateResolver', function() {
249+
describe('_createResolver', function() {
250250
it('should resolve to raw values', function() {
251251
const defaults = {
252252
color: 'red',
@@ -405,7 +405,49 @@ describe('Chart.helpers.options', function() {
405405
});
406406
});
407407

408+
it('should resolve array of non-indexable objects properly', function() {
409+
const defaults = {
410+
label: {
411+
value: 42,
412+
text: (ctx) => ctx.text
413+
},
414+
labels: {
415+
_fallback: 'label',
416+
_indexable: false
417+
}
418+
};
419+
420+
const options = {
421+
labels: [{text: 'a'}, {text: 'b'}, {value: 1}]
422+
};
423+
const opts = _attachContext(_createResolver([options, defaults]), {text: 'context'});
424+
expect(opts.labels).toEqualOptions([
425+
{
426+
text: 'a',
427+
value: 42
428+
},
429+
{
430+
text: 'b',
431+
value: 42
432+
},
433+
{
434+
text: 'context',
435+
value: 1
436+
}
437+
]);
438+
});
439+
408440
describe('_indexable and _scriptable', function() {
441+
it('should default to true', function() {
442+
const options = {
443+
array: [1, 2, 3],
444+
func: (ctx) => ctx.index * 10
445+
};
446+
const opts = _attachContext(_createResolver([options]), {index: 1});
447+
expect(opts.array).toEqual(2);
448+
expect(opts.func).toEqual(10);
449+
});
450+
409451
it('should allow false', function() {
410452
const fn = () => 'test';
411453
const options = {

0 commit comments

Comments
 (0)