@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
50 lines • 2.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsdom_1 = require("jsdom");
const filter_attributes_1 = require("./filter-attributes");
describe('filterAttributes', () => {
it('should filter Angular attributes', () => {
const doc = new jsdom_1.JSDOM(`
<kendo-grid-list ng-reflect-data="[object Object],[object Object" _ng-attr="true"></kendo-grid-list>
`).window.document;
(0, filter_attributes_1.filterAttributes)(doc, doc.documentElement);
expect(doc.querySelector('kendo-grid-list').getAttribute('ng-reflect-data')).toBeNull();
expect(doc.querySelector('kendo-grid-list').getAttribute('_ng-attr')).toBeNull();
});
it('should filter data attributes', () => {
const doc = new jsdom_1.JSDOM(`
<div data-foo="2"></div>
`).window.document;
(0, filter_attributes_1.filterAttributes)(doc, doc.documentElement);
expect(doc.querySelector('div').getAttribute('data-foo')).toBeNull();
});
it('should filter empty attributes', () => {
const doc = new jsdom_1.JSDOM(`
<div kendodraggable=""></div>
`).window.document;
(0, filter_attributes_1.filterAttributes)(doc, doc.documentElement);
expect(doc.querySelector('div').getAttribute('kendodraggable')).toBeNull();
});
it('should not filter standard empty attributes', () => {
const doc = new jsdom_1.JSDOM(`
<input checked readonly />
<select name="choice">
<option value="first" selected>First Value</option>
</select>
`).window.document;
(0, filter_attributes_1.filterAttributes)(doc, doc.documentElement);
expect(doc.querySelector('input').getAttribute('checked')).toBe('');
expect(doc.querySelector('input').getAttribute('readonly')).toBe('');
expect(doc.querySelector('option').getAttribute('selected')).toBe('');
});
it('should filter attributes with GUID values', () => {
const doc = new jsdom_1.JSDOM(`
<input id="a23ae29e-06d2-4cb8-a76e-263fa9a3338e" type="checkbox" class="k-checkbox">
<label class="k-checkbox-label" for="a23ae29e-06d2-4cb8-a76e-263fa9a3338e"></label>
`).window.document;
(0, filter_attributes_1.filterAttributes)(doc, doc.documentElement);
expect(doc.querySelector('input').getAttribute('id')).toBeNull();
expect(doc.querySelector('label').getAttribute('for')).toBeNull();
});
});
//# sourceMappingURL=filter-attributes.spec.js.map