Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit f6b2eda

Browse files
committed
test(core): increase l-bind coverage
1 parent b1e2417 commit f6b2eda

File tree

2 files changed

+45
-44
lines changed

2 files changed

+45
-44
lines changed

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4+
printf "Making sure your changes are okay, hold tight!"
45
npx --no-install lint-staged --quiet

src/core/directives/__test__/bind.spec.ts

+44-44
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ describe('.bindDirective', () => {
2929
expect(el.className).toEqual('test2');
3030
});
3131

32-
// it('should not have className prop', () => {
33-
// const el = document.createElement('p');
34-
// const expression = '{ test: test }';
35-
// const state = { test: false };
36-
// bindDirective({
37-
// el,
38-
// parts: ['bind', 'class'],
39-
// data: { value: expression, compute: compute(expression, el), deps: [] },
40-
// state,
41-
// });
42-
// expect(el.className).toEqual('');
43-
// });
32+
it('should not have className prop', () => {
33+
const el = document.createElement('p');
34+
const expression = '{ test: test }';
35+
const state = { test: false };
36+
bindDirective({
37+
el,
38+
parts: ['bind', 'class'],
39+
data: { value: expression, compute: compute(expression, el), deps: [] },
40+
state,
41+
});
42+
expect(el.className).toEqual('');
43+
});
4444

4545
it('should accept string for class', () => {
4646
const el = document.createElement('p');
@@ -68,18 +68,18 @@ describe('.bindDirective', () => {
6868
expect(el.className).toEqual('foo bar baz');
6969
});
7070

71-
// it('should bind style based on state value', () => {
72-
// const el = document.createElement('p');
73-
// const expression = '{ fontWeight: test }';
74-
// const state = { test: 'bold' };
75-
// bindDirective({
76-
// el,
77-
// parts: ['bind', 'style'],
78-
// data: { value: expression, compute: compute(expression, el), deps: ['test'] },
79-
// state,
80-
// });
81-
// expect(el.style.cssText).toEqual('font-weight: bold;');
82-
// });
71+
it('should bind style based on state value', () => {
72+
const el = document.createElement('p');
73+
const expression = '{ fontWeight: test }';
74+
const state = { test: 'bold' };
75+
bindDirective({
76+
el,
77+
parts: ['bind', 'style'],
78+
data: { value: expression, compute: compute(expression, el), deps: ['test'] },
79+
state,
80+
});
81+
expect(el.style.cssText).toEqual('font-weight: bold;');
82+
});
8383

8484
it('should bind href to anchor tag based on state value', () => {
8585
const el = document.createElement('a');
@@ -94,26 +94,26 @@ describe('.bindDirective', () => {
9494
expect(el.href).toEqual('https://example.com/');
9595
});
9696

97-
// it('should allow boolean input for attributes', () => {
98-
// const el = document.createElement('a');
99-
// const expression = 'hideme';
100-
// let state = { hideme: true };
101-
// bindDirective({
102-
// el,
103-
// parts: ['bind', 'hidden'],
104-
// data: { value: expression, compute: compute(expression, el), deps: [] },
105-
// state,
106-
// });
107-
// expect(el.hidden).toEqual(true);
108-
// state = { hideme: false };
109-
// bindDirective({
110-
// el,
111-
// parts: ['bind', 'hidden'],
112-
// data: { value: expression, compute: compute(expression, el), deps: [] },
113-
// state,
114-
// });
115-
// expect(el.hidden).toEqual(false);
116-
// });
97+
it('should allow boolean input for attributes', () => {
98+
const el = document.createElement('a');
99+
const expression = 'hideme';
100+
let state = { hideme: true };
101+
bindDirective({
102+
el,
103+
parts: ['bind', 'hidden'],
104+
data: { value: expression, compute: compute(expression, el), deps: [] },
105+
state,
106+
});
107+
expect(el.hidden).toEqual(true);
108+
state = { hideme: false };
109+
bindDirective({
110+
el,
111+
parts: ['bind', 'hidden'],
112+
data: { value: expression, compute: compute(expression, el), deps: [] },
113+
state,
114+
});
115+
expect(el.hidden).toEqual(false);
116+
});
117117

118118
it('should accept object format for attributes', () => {
119119
const el = document.createElement('a');

0 commit comments

Comments
 (0)