Skip to content

Commit

Permalink
Disable a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveTryon committed Jul 7, 2023
1 parent 33c8cda commit fae7c45
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,40 @@

exports[`CollapsibleScriptProvider produces script source that matches snapshot 1`] = `
"(function addEventListenerForCollapsibleSection(doc) {
var _loop = function(index) {
var _container;
var container = collapsibles.item(index);
var button = (_container = container) === null || _container === void 0 ? void 0 : _container.querySelector('.collapsible-control');
if (button == null) {
return "continue";
}
button.addEventListener('click', function() {
var _button_parentElement;
var content = (_button_parentElement = button.parentElement) === null || _button_parentElement === void 0 ? void 0 : _button_parentElement.nextElementSibling;
if (content == null) {
throw Error("Expected button element's parent to have a next sibling");
}
var wasExpandedBefore = button.getAttribute('aria-expanded') === 'false' ? false : true;
var isExpandedAfter = !wasExpandedBefore;
button.setAttribute('aria-expanded', isExpandedAfter + '');
content.setAttribute('aria-hidden', !isExpandedAfter + '');
if (isExpandedAfter) {
container.classList.remove('collapsed');
} else {
container.classList.add('collapsed');
}
});
};
var collapsibles = doc.getElementsByClassName('collapsible-container');
for(var index = 0; index < collapsibles.length; index++)_loop(index);
})(document)"
var _loop = function (index) {
var _container;
var container = collapsibles.item(index);
var button =
(_container = container) === null || _container === void 0
? void 0
: _container.querySelector(".collapsible-control");
if (button == null) {
return "continue";
}
button.addEventListener("click", function () {
var _button_parentElement;
var content =
(_button_parentElement = button.parentElement) === null ||
_button_parentElement === void 0
? void 0
: _button_parentElement.nextElementSibling;
if (content == null) {
throw Error("Expected button element's parent to have a next sibling");
}
var wasExpandedBefore =
button.getAttribute("aria-expanded") === "false" ? false : true;
var isExpandedAfter = !wasExpandedBefore;
button.setAttribute("aria-expanded", isExpandedAfter + "");
content.setAttribute("aria-hidden", !isExpandedAfter + "");
if (isExpandedAfter) {
container.classList.remove("collapsed");
} else {
container.classList.add("collapsed");
}
});
};
var collapsibles = doc.getElementsByClassName("collapsible-container");
for (var index = 0; index < collapsibles.length; index++) _loop(index);
})(document);
"
`;
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { isFunction } from 'lodash';
//import { format } from 'prettier';
// import { format } from 'prettier';
import {
addEventListenerForCollapsibleSection,
getDefaultAddListenerForCollapsibleSection,
} from 'reports/components/report-sections/collapsible-script-provider';
import { It, Mock, MockBehavior, Times } from 'typemoq';

describe('CollapsibleScriptProvider', () => {
it('produces script source that matches snapshot', () => {
const source = getDefaultAddListenerForCollapsibleSection();
// Required to get a consistent snapshot with --coverage=false vs --coverage=true
// const formattedSource = (await format(source, { parser: 'babel' })).replace(/\n\n/g, '\n');
const formattedSource = source.replace(/\n\n/g, '\n');
expect(formattedSource).toMatchSnapshot();
});
// it('produces script source that matches snapshot', async () => {
// const source = getDefaultAddListenerForCollapsibleSection();
// // Required to get a consistent snapshot with --coverage=false vs --coverage=true
// const formattedSource = (await format(source, { parser: 'babel' })).replace(/\n\n/g, '\n');
// expect(formattedSource).toMatchSnapshot();
// });

it('produces script source that does not use IE-incompatible arrow functions', () => {
const result = getDefaultAddListenerForCollapsibleSection();
Expand Down

0 comments on commit fae7c45

Please sign in to comment.