Skip to content

Commit bbe37b5

Browse files
committed
Add test for attribute name transformation
1 parent 6214991 commit bbe37b5

File tree

2 files changed

+510
-0
lines changed

2 files changed

+510
-0
lines changed

test/render.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render, shallowRender } from '../src';
2+
import { possibleStandardNames } from './utils';
23
import { h, Component, createContext, Fragment, options } from 'preact';
34
import { useState, useContext, useEffect, useLayoutEffect } from 'preact/hooks';
45
import { expect } from 'chai';
@@ -89,6 +90,16 @@ describe('render', () => {
8990
expect(rendered).to.equal(expected);
9091
});
9192

93+
it('should transform attribute names to html standard name', () => {
94+
Object.entries(possibleStandardNames).forEach(([standardName, name]) => {
95+
let props = { [name]: 'test' },
96+
rendered = render(<div {...props} />),
97+
expected = `<div ${standardName}="test"></div>`;
98+
99+
expect(rendered).to.equal(expected);
100+
});
101+
});
102+
92103
it('should include boolean aria-* attributes', () => {
93104
let rendered = render(<div aria-hidden aria-whatever={false} />),
94105
expected = `<div aria-hidden="true" aria-whatever="false"></div>`;

0 commit comments

Comments
 (0)