1
+ import { uniq } from '@antv/util' ;
1
2
import { IGroup } from '@antv/g2/lib/dependents' ;
2
3
import { Column , ColumnOptions , Bar , BarOptions } from '../../../src' ;
3
4
import { createDiv } from '../../utils/dom' ;
@@ -54,6 +55,9 @@ describe('column conversion tag', () => {
54
55
55
56
// 文本
56
57
const texts = group . findAllByName ( 'conversion-tag-text' ) ;
58
+ const textIds = texts . map ( ( text ) => text . get ( 'id' ) ) as string [ ] ;
59
+ // 每一个都有唯一的 ID
60
+ expect ( uniq ( textIds ) ) . toHaveLength ( DATA . length - 1 ) ;
57
61
expect ( texts ) . toHaveLength ( DATA . length - 1 ) ;
58
62
DATA . forEach ( ( datum , idx ) => {
59
63
if ( idx > 0 ) {
@@ -64,6 +68,9 @@ describe('column conversion tag', () => {
64
68
65
69
// 箭头
66
70
const arrows = group . findAllByName ( 'conversion-tag-arrow' ) ;
71
+ const arrowIds = arrows . map ( ( arrow ) => arrow . get ( 'id' ) ) as string [ ] ;
72
+ // 每一个都有唯一的 ID
73
+ expect ( uniq ( arrowIds ) ) . toHaveLength ( DATA . length - 1 ) ;
67
74
expect ( arrows ) . toHaveLength ( DATA . length - 1 ) ;
68
75
arrows . forEach ( ( arrow ) => {
69
76
const bbox = arrow . getBBox ( ) ;
@@ -99,6 +106,9 @@ describe('column conversion tag', () => {
99
106
100
107
// 文本
101
108
const texts = group . findAllByName ( 'conversion-tag-text' ) ;
109
+ const textIds = texts . map ( ( text ) => text . get ( 'id' ) ) as string [ ] ;
110
+ // 每一个都有唯一的 ID
111
+ expect ( uniq ( textIds ) ) . toHaveLength ( DATA . length - 1 ) ;
102
112
expect ( texts ) . toHaveLength ( DATA . length - 1 ) ;
103
113
DATA . slice ( )
104
114
. reverse ( )
@@ -111,6 +121,9 @@ describe('column conversion tag', () => {
111
121
112
122
// 箭头
113
123
const arrows = group . findAllByName ( 'conversion-tag-arrow' ) ;
124
+ const arrowIds = arrows . map ( ( arrow ) => arrow . get ( 'id' ) ) as string [ ] ;
125
+ // 每一个都有唯一的 ID
126
+ expect ( uniq ( arrowIds ) ) . toHaveLength ( DATA . length - 1 ) ;
114
127
expect ( arrows ) . toHaveLength ( DATA . length - 1 ) ;
115
128
arrows . forEach ( ( arrow ) => {
116
129
const bbox = arrow . getBBox ( ) ;
@@ -173,6 +186,9 @@ describe('bar conversion tag', () => {
173
186
174
187
// 文本
175
188
const texts = group . findAllByName ( 'conversion-tag-text' ) ;
189
+ const textIds = texts . map ( ( text ) => text . get ( 'id' ) ) as string [ ] ;
190
+ // 每一个都有唯一的 ID
191
+ expect ( uniq ( textIds ) ) . toHaveLength ( DATA . length - 1 ) ;
176
192
expect ( texts ) . toHaveLength ( DATA . length - 1 ) ;
177
193
DATA . forEach ( ( datum , idx ) => {
178
194
if ( idx > 0 ) {
@@ -183,6 +199,9 @@ describe('bar conversion tag', () => {
183
199
184
200
// 箭头
185
201
const arrows = group . findAllByName ( 'conversion-tag-arrow' ) ;
202
+ const arrowIds = arrows . map ( ( arrow ) => arrow . get ( 'id' ) ) as string [ ] ;
203
+ // 每一个都有唯一的 ID
204
+ expect ( uniq ( arrowIds ) ) . toHaveLength ( DATA . length - 1 ) ;
186
205
expect ( arrows ) . toHaveLength ( DATA . length - 1 ) ;
187
206
arrows . forEach ( ( arrow ) => {
188
207
const bbox = arrow . getBBox ( ) ;
@@ -218,6 +237,9 @@ describe('bar conversion tag', () => {
218
237
219
238
// 文本
220
239
const texts = group . findAllByName ( 'conversion-tag-text' ) ;
240
+ const textIds = texts . map ( ( text ) => text . get ( 'id' ) ) as string [ ] ;
241
+ // 每一个都有唯一的 ID
242
+ expect ( uniq ( textIds ) ) . toHaveLength ( DATA . length - 1 ) ;
221
243
expect ( texts ) . toHaveLength ( DATA . length - 1 ) ;
222
244
DATA . forEach ( ( datum , idx ) => {
223
245
if ( idx > 0 ) {
@@ -228,6 +250,9 @@ describe('bar conversion tag', () => {
228
250
229
251
// 箭头
230
252
const arrows = group . findAllByName ( 'conversion-tag-arrow' ) ;
253
+ const arrowIds = arrows . map ( ( arrow ) => arrow . get ( 'id' ) ) as string [ ] ;
254
+ // 每一个都有唯一的 ID
255
+ expect ( uniq ( arrowIds ) ) . toHaveLength ( DATA . length - 1 ) ;
231
256
expect ( arrows ) . toHaveLength ( DATA . length - 1 ) ;
232
257
arrows . forEach ( ( arrow ) => {
233
258
const bbox = arrow . getBBox ( ) ;
0 commit comments