Skip to content

Commit

Permalink
Just check against the current document lang
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend committed Sep 1, 2023
1 parent 02ab688 commit 9ecc8f2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"access": "public"
},
"dependencies": {
"@brightspace-ui/intl": "^3",
"@open-wc/testing": "^3",
"@rollup/plugin-node-resolve": "^15",
"@web/config-loader": "^0.2",
Expand Down
8 changes: 2 additions & 6 deletions src/browser/reset.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { sendMouse, setViewport } from '@web/test-runner-commands';
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
import { nextFrame } from '@open-wc/testing';

const DEFAULT_LANG = 'en',
DEFAULT_MATHJAX_RENDER_LATEX = false,
DEFAULT_VIEWPORT_HEIGHT = 800,
DEFAULT_VIEWPORT_WIDTH = 800;

const documentLocaleSettings = getDocumentLocaleSettings();

let
currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX,
currentRtl = false,
Expand Down Expand Up @@ -60,9 +57,8 @@ export async function reset(opts = {}) {
currentRtl = opts.rtl;
}

if (opts.lang !== documentLocaleSettings.language) {
document.documentElement.setAttribute('lang', opts.lang);
documentLocaleSettings.language = opts.lang;
if (document.documentElement.lang !== opts.lang) {
document.documentElement.lang = opts.lang;
awaitNextFrame = true;
}

Expand Down
6 changes: 0 additions & 6 deletions test/browser/fixture.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
import { defineCE, expect, fixture, html, waitUntil } from '../../src/browser/index.js';
import { restore, stub } from 'sinon';
import { focusElem } from '../../src/browser/commands.js';
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
import { LitElement } from 'lit';
import { requestMouseReset } from '../../src/browser/reset.js';
import { sendMouse } from '@web/test-runner-commands';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';

const documentLocaleSettings = getDocumentLocaleSettings();

const resolves = new Map();

const slowElem = defineCE(
Expand Down Expand Up @@ -135,16 +132,13 @@ describe('fixture', () => {
it('should default language to EN', async() => {
await fixture(html`<p>hello</p>`);
expect(document.documentElement.getAttribute('lang')).to.equal('en');
expect(documentLocaleSettings.language).to.equal('en');
});

it('should reset language to EN', async() => {
await fixture(html`<p>bonjour</p>`, { lang: 'fr' });
expect(document.documentElement.getAttribute('lang')).to.equal('fr');
expect(documentLocaleSettings.language).to.equal('fr');
await fixture(html`<p>hello</p>`);
expect(document.documentElement.getAttribute('lang')).to.equal('en');
expect(documentLocaleSettings.language).to.equal('en');
});

it('should use specified mathjax latex config', async() => {
Expand Down

0 comments on commit 9ecc8f2

Please sign in to comment.