Skip to content

Commit

Permalink
Add test for DecimationAlgorithm type (#9010)
Browse files Browse the repository at this point in the history
* Add test for DecimationAlgorithm type
* Allow strings to be set
* Linting
  • Loading branch information
etimberg committed May 1, 2021
1 parent 55dd426 commit ea7b8cb
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/index.esm.d.ts
Expand Up @@ -1961,12 +1961,12 @@ interface BaseDecimationOptions {
}

interface LttbDecimationOptions extends BaseDecimationOptions {
algorithm: DecimationAlgorithm.lttb;
algorithm: DecimationAlgorithm.lttb | 'lttb';
samples?: number;
}

interface MinMaxDecimationOptions extends BaseDecimationOptions {
algorithm: DecimationAlgorithm.minmax;
algorithm: DecimationAlgorithm.minmax | 'min-max';
}

export type DecimationOptions = LttbDecimationOptions | MinMaxDecimationOptions;
Expand Down
72 changes: 72 additions & 0 deletions types/tests/plugins/plugin.decimation/decimation_algorithm.ts
@@ -0,0 +1,72 @@
import { Chart, DecimationAlgorithm } from '../../../index.esm';

const chart = new Chart('id', {
type: 'bubble',
data: {
labels: [],
datasets: [{
data: []
}]
},
options: {
plugins: {
decimation: {
algorithm: DecimationAlgorithm.lttb,
}
}
}
});


const chart2 = new Chart('id', {
type: 'bubble',
data: {
labels: [],
datasets: [{
data: []
}]
},
options: {
plugins: {
decimation: {
algorithm: 'lttb',
}
}
}
});


const chart3 = new Chart('id', {
type: 'bubble',
data: {
labels: [],
datasets: [{
data: []
}]
},
options: {
plugins: {
decimation: {
algorithm: DecimationAlgorithm.minmax,
}
}
}
});


const chart4 = new Chart('id', {
type: 'bubble',
data: {
labels: [],
datasets: [{
data: []
}]
},
options: {
plugins: {
decimation: {
algorithm: 'min-max',
}
}
}
});

0 comments on commit ea7b8cb

Please sign in to comment.