Skip to content

Commit

Permalink
add failing test for buggy behaviour in a separate test case and skip…
Browse files Browse the repository at this point in the history
… it until fixed
  • Loading branch information
leonbubova committed Aug 1, 2022
1 parent 34551ba commit 0ef1b75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Extensions/combined/src/__snapshots__/utils.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ exports[`getNumberFormatter should return a correct formatter when using chrome

exports[`getNumberFormatter should return a correct formatter when using firefox 1`] = `NumberFormat {}`;

exports[`getNumberFormatter should return a correct formatter when using the URL locale (possibly buggy) 1`] = `NumberFormat {}`;

exports[`getNumberFormatter should return a correct formatter when using the URL locale 1`] = `NumberFormat {}`;

exports[`getNumberFormatter should return a correct formatter whith standard option 1`] = `NumberFormat {}`;
Expand Down
22 changes: 19 additions & 3 deletions Extensions/combined/src/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("getNumberFormatter", () => {
expect(getNumberFormatter()).toMatchSnapshot();
});

it("should return a correct formatter when using the URL locale", () => {
it("should return a correct formatter when using the URL locale (possibly buggy)", () => {
// Disclaimer: The case we are testing here is actually not correct and
// am almost sure I found a bug in the actual implementation of
// getNumberFormatter(). As I am currently writing acceptance tests only
Expand All @@ -109,6 +109,8 @@ describe("getNumberFormatter", () => {
// for now and document how we should actually be testing down below.
// The reason why this bug is not causing faulty behaviour is, that we
// have a fallback for it, that is always triggered.

// This is how we make the test go green:
Object.defineProperty(document.documentElement, "lang", {
value: null,
configurable: true,
Expand All @@ -119,13 +121,27 @@ describe("getNumberFormatter", () => {
});
const mockedNode = document.createElement("link");

// This is how we make the test go green:
mockedNode.setAttribute(
"href",
"https://www.youtube.com/opensearch?locale=en"
);

document.querySelectorAll = jest.fn().mockReturnValue([mockedNode]);
expect(getNumberFormatter()).toMatchSnapshot();
});

it.skip("should return a correct formatter when using the URL locale", () => {
// But we actually want to test like so, which is the correct value of the locale attribute:
// mockedNode.setAttribute("href", "https://www.youtube.com/opensearch?locale=en_US");
Object.defineProperty(document.documentElement, "lang", {
value: null,
configurable: true,
});
Object.defineProperty(navigator, "language", {
value: null,
configurable: true,
});
const mockedNode = document.createElement("link");
mockedNode.setAttribute("href", "https://www.youtube.com/opensearch?locale=en_US");

document.querySelectorAll = jest.fn().mockReturnValue([mockedNode]);
expect(getNumberFormatter()).toMatchSnapshot();
Expand Down

0 comments on commit 0ef1b75

Please sign in to comment.