1
+ import { MockAttr , MockAttributeMap } from '../attribute' ;
1
2
import { MockDocument } from '../document' ;
2
3
import { MockElement , MockHTMLElement } from '../node' ;
3
4
import { XLINK_NS } from '../../runtime/runtime-constants' ;
4
- import { MockImageElement } from '../element' ;
5
5
6
6
describe ( 'attributes' , ( ) => {
7
7
let doc : MockDocument ;
8
8
beforeEach ( ( ) => {
9
9
doc = new MockDocument ( ) ;
10
10
} ) ;
11
11
12
+ it ( 'attribute map is iterable' , ( ) => {
13
+ const map = new MockAttributeMap ( ) ;
14
+ const attr = new MockAttr ( 'attr' , 'value' ) ;
15
+ map . setNamedItem ( attr ) ;
16
+
17
+ expect ( Array . from ( map ) [ 0 ] ) . toBe ( attr ) ;
18
+ } ) ;
19
+
12
20
it ( 'should get attributes by index' , ( ) => {
13
21
const element = new MockHTMLElement ( doc , 'div' ) ;
14
22
element . setAttribute ( 'attr-0' , 'value-0' ) ;
@@ -67,7 +75,9 @@ describe('attributes', () => {
67
75
expect ( element . getAttribute ( 'prop5' ) ) . toBe ( 'hola' ) ;
68
76
expect ( element . getAttribute ( 'prop6' ) ) . toBe ( '' ) ;
69
77
70
- expect ( element ) . toEqualHtml ( `<div prop1=\"null\" prop2=\"undefined\" prop3=\"0\" prop4=\"1\" prop5=\"hola\" prop6></div>` ) ;
78
+ expect ( element ) . toEqualHtml (
79
+ `<div prop1=\"null\" prop2=\"undefined\" prop3=\"0\" prop4=\"1\" prop5=\"hola\" prop6></div>` ,
80
+ ) ;
71
81
} ) ;
72
82
73
83
it ( 'should cast attributeNS values to string' , ( ) => {
@@ -86,7 +96,9 @@ describe('attributes', () => {
86
96
expect ( element . getAttribute ( 'prop5' ) ) . toBe ( 'hola' ) ;
87
97
expect ( element . getAttribute ( 'prop6' ) ) . toBe ( '' ) ;
88
98
89
- expect ( element ) . toEqualHtml ( `<div prop1=\"null\" prop2=\"undefined\" prop3=\"0\" prop4=\"1\" prop5=\"hola\" prop6></div>` ) ;
99
+ expect ( element ) . toEqualHtml (
100
+ `<div prop1=\"null\" prop2=\"undefined\" prop3=\"0\" prop4=\"1\" prop5=\"hola\" prop6></div>` ,
101
+ ) ;
90
102
} ) ;
91
103
92
104
it ( 'attributes are case insensible in HTMLElement' , ( ) => {
@@ -126,7 +138,7 @@ describe('attributes', () => {
126
138
} ) ;
127
139
128
140
it ( 'draggable default value' , ( ) => {
129
- const div = doc . createElement ( 'div' )
141
+ const div = doc . createElement ( 'div' ) ;
130
142
expect ( div . draggable ) . toEqual ( false ) ;
131
143
132
144
const img = doc . createElement ( 'img' ) ;
0 commit comments