Skip to content

Commit 0e208ee

Browse files
committed
chore: re-added global attributes trait test
1 parent f24e9e7 commit 0e208ee

3 files changed

Lines changed: 20 additions & 42 deletions

File tree

src/Trait/GlobalAttribute/DirTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait DirTrait
1212
/**
1313
* Represents the text direction of the element
1414
*/
15-
private ?DirectionEnum $dir = null;
15+
protected ?DirectionEnum $dir = null;
1616

1717
/**
1818
* @todo sounds like enum

src/Trait/GlobalAttribute/DraggableTrait.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ public function setDraggable(bool|string $draggable = true): static
1919
if (is_string($draggable) && in_array($draggable, ['true', 'false'])) {
2020
$draggable = $draggable === 'true' ? true : false;
2121
}
22-
if ($draggable) {
23-
$this->draggable = $draggable;
24-
$this->setAttribute('draggable', $draggable);
25-
$this->delegated->setAttribute('draggable', $draggable);
26-
}
22+
$this->draggable = $draggable;
23+
$this->setAttribute('draggable', $draggable ? 'true' : 'false');
2724
return $this;
2825
}
2926

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<?php
22

33
use Html\Delegator\HTMLDocumentDelegator;
4+
use Html\Element\Block\Division;
45
use Html\Enum\AutoCapitalizeEnum;
56
use Html\Enum\ContentEditableEnum;
67
use Html\Enum\DirectionEnum;
78
use Html\Enum\SpellCheckEnum;
89

9-
// uses(\Html\Trait\GlobalAttributesTrait::class);
10-
1110
beforeEach(function () {
1211
$this->document = HTMLDocumentDelegator::createEmpty();
13-
$this->element = $this->document->createElement('div');
12+
$this->element = Division::create($this->document);
1413
});
1514

1615
test('set and get access key', function () {
@@ -115,12 +114,6 @@
115114
->toEqual(true);
116115
});
117116

118-
test('set and get inert', function () {
119-
$this->element->setInert(true);
120-
expect($this->element->getInert())
121-
->toEqual(true);
122-
});
123-
124117
test('set and get input mode', function () {
125118
$this->element->setInputMode('numeric');
126119
expect($this->element->getInputMode()->value)
@@ -137,40 +130,26 @@
137130
$this->element->setInputMode('phone');
138131
});
139132

140-
test('set and get is', function () {
141-
$this->element->setIs('custom-element');
142-
expect($this->element->getIs())
143-
->toEqual('custom-element');
144-
});
145-
146133
test('set and get lang', function () {
147134
$this->element->setLang('en');
148135
expect($this->element->getLang())
149136
->toEqual('en');
150137
});
151138

152-
test('set and get nonce', function () {
153-
$this->element->setNonce('random-nonce');
154-
expect($this->element->getNonce())
155-
->toEqual('random-nonce');
156-
});
157-
158-
test('set and get part', function () {
159-
$this->element->setPart('part-name');
160-
expect($this->element->getPart())
161-
->toEqual('part-name');
162-
});
163-
164139
test('set and get popover', function () {
165140
$this->element->setPopover('auto');
166-
expect($this->element->getPopover())
141+
expect($this->element->getPopover()->value)
167142
->toEqual('auto');
143+
expect($this->element->getPopover())
144+
->toEqual(\Html\Enum\PopoverEnum::AUTO);
168145
});
169146

170147
test('set and get role', function () {
171148
$this->element->setRole('button');
172-
expect($this->element->getRole())
149+
expect($this->element->getRole()->value)
173150
->toEqual('button');
151+
expect($this->element->getRole())
152+
->toEqual(\Html\Enum\RoleEnum::BUTTON);
174153
});
175154

176155
test('set and get slot', function () {
@@ -180,20 +159,20 @@
180159
});
181160

182161
test('set and get spell check', function () {
183-
$this->element->setSpellCheck(true);
184-
expect($this->element->getSpellCheck())
162+
$this->element->setSpellcheck(true);
163+
expect($this->element->getSpellcheck())
185164
->toBeInstanceOf(SpellCheckEnum::class);
186-
expect($this->element->getSpellCheck()->value)
165+
expect($this->element->getSpellcheck()->value)
187166
->toEqual('true');
188167
expect($this->element->delegated->getAttribute('spellcheck'))
189168
->toEqual('true');
190169

191170
$this->expectException(InvalidArgumentException::class);
192171
$this->expectExceptionMessage('Invalid value for spellcheck');
193-
$this->element->setSpellCheck('invalid-value');
172+
$this->element->setSpellcheck('invalid-value');
194173

195-
$this->element->setSpellCheck('true');
196-
expect($this->element->getSpellCheck())
174+
$this->element->setSpellcheck('true');
175+
expect($this->element->getSpellcheck())
197176
->toBeInstanceOf(SpellCheckEnum::class);
198177
});
199178

@@ -217,8 +196,10 @@
217196

218197
test('set and get translate', function () {
219198
$this->element->setTranslate('yes');
220-
expect($this->element->getTranslate())
199+
expect($this->element->getTranslate()->value)
221200
->toEqual('yes');
201+
expect($this->element->getTranslate())
202+
->toEqual(\Html\Enum\TranslateEnum::YES);
222203
});
223204

224205
test('test setDataAttribute', function () {

0 commit comments

Comments
 (0)