From ba91438b911e03fe63502912f3dcef6289b1763d Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Mon, 4 Mar 2024 16:04:46 +0100 Subject: [PATCH] Removed the old tests. Fixed type definitions. --- tests/unit.test.js | 75 --------------------------------------- types/highcharts-vue.d.ts | 16 ++++----- 2 files changed, 8 insertions(+), 83 deletions(-) delete mode 100644 tests/unit.test.js diff --git a/tests/unit.test.js b/tests/unit.test.js deleted file mode 100644 index 3fee64a..0000000 --- a/tests/unit.test.js +++ /dev/null @@ -1,75 +0,0 @@ -import { mount } from '@vue/test-utils' -import { Chart } from '../src/' -import Highcharts from 'highcharts' - -const propsData = { - options: { - series: [{ - name: 'Series', - data: [1, 2, 3] - }] - }, - callback: function () { - this.wasCallbackInvoked = true - } -} - -describe('highcharts-vue tests', () => { - const wrapper = mount(Chart, { propsData }) - const chart = Highcharts.charts[0] - - test('Wrapper should be a Vue instance.', () => { - expect(wrapper.vm).toBeTruthy() - }) - - test('Only one chart should be created.', () => { - expect(Highcharts.charts.length).toBe(1) - }) - - test('Chart data should be set correctly.', () => { - expect( - wrapper.props().options.series[0].data - ).toEqual( - chart.series[0].yData - ) - }) - - test('Callback should be invoked.', () => { - expect(chart.wasCallbackInvoked).toBeTruthy() - }) - - test('Chart data should be copied.', async () => { - await wrapper.setProps({ - options: { - series: [{ - name: 'Series', - data: [1, 2, 3, 9] - }] - } - }) - - expect( - wrapper.props('options').series[0].data === chart.series[0].userOptions.data - ).not.toBeTruthy() - }) - - test('Chart data should not be copied.', async () => { - await wrapper.setProps({ - deepCopyOnUpdate: false, - options: { - series: [{ - data: [12, 10, 5, 6, 10] - }] - } - }) - - expect( - wrapper.props('options').series[0].data === chart.series[0].userOptions.data - ).toBeTruthy() - }) - - test('Chart should be destroyed when component is destroyed.', () => { - wrapper.destroy() - expect(Highcharts.charts[0]).not.toBeTruthy() - }) -}) diff --git a/types/highcharts-vue.d.ts b/types/highcharts-vue.d.ts index 2442db0..97a96b0 100644 --- a/types/highcharts-vue.d.ts +++ b/types/highcharts-vue.d.ts @@ -2,14 +2,6 @@ import { DefineComponent, App } from 'vue'; import * as Highcharts from 'highcharts'; -declare module '@vue/runtime-cor' { - export interface GlobalComponents { - [key: string]: DefineComponent - } -} - -export type ChartUpdateArgs = [boolean, boolean, Highcharts.AnimationOptionsObject]; - export interface ChartProps { constructorType?: string; options: Highcharts.Options; @@ -19,6 +11,14 @@ export interface ChartProps { deepCopyOnUpdate?: boolean; } +declare module '@vue/runtime-core' { + export interface GlobalComponents { + [key: string]: DefineComponent + } +} + +export type ChartUpdateArgs = [boolean, boolean, Highcharts.AnimationOptionsObject]; + export const Chart: DefineComponent; export interface HCVueInstallOptions {