From 548278e37944ec9f8d378fb36afafcc252e00861 Mon Sep 17 00:00:00 2001 From: hustcc Date: Sun, 7 Feb 2021 10:34:56 +0800 Subject: [PATCH] test: add test for vis @antv/g2plot (#79) * test: add test case for vis library * fix: typo --- __tests__/vis.js | 29 +++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 __tests__/vis.js diff --git a/__tests__/vis.js b/__tests__/vis.js new file mode 100644 index 0000000..3dd8925 --- /dev/null +++ b/__tests__/vis.js @@ -0,0 +1,29 @@ +/** + * test vis @AntV/G2Plot + */ + +import { Line } from '@antv/g2plot'; + +describe('vis', () => { + it('vis can pass', () => { + const div = document.createElement('canvas'); + + const line = new Line(div, { + data: [ + { x: 'A', y: 10 }, + { x: 'B', y: 20 }, + { x: 'C', y: 30 }, + ], + xField: 'x', + yField: 'y', + }); + + line.render(); + + expect(line.container.querySelector('canvas')).not.toBe(null); + + line.destroy(); + + expect(line.container.querySelector('canvas')).toBe(null); + }); +}); diff --git a/package.json b/package.json index c7005d9..8544b07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-canvas-mock", - "version": "2.2.0", + "version": "2.2.1", "description": "Mock a canvas in your jest tests.", "main": "lib/index.js", "types": "types/index.d.ts", @@ -16,6 +16,7 @@ "moo-color": "^1.0.2" }, "devDependencies": { + "@antv/g2plot": "^2.3.11", "@babel/cli": "^7.8.4", "@babel/core": "^7.9.0", "@babel/plugin-proposal-class-properties": "^7.8.3",