@brightspace-ui/testing 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -208,6 +208,8 @@ it('should wait for an event', async() => {
208
208
 
209
209
  Note that the call to `clickElem` is not `await`-ed, since by the time it resolves the event will have already been dispatched.
210
210
 
211
+ If you need to prevent the default behaviour of the event in your test, you can use `oneDefaultPreventedEvent`.
212
+
211
213
  #### Waiting for a Lit Element to Update
212
214
 
213
215
  When using Lit-based components, it's common to create a fixture and then modify some of its properties, which usually requires waiting for those changes to be rendered.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@brightspace-ui/testing",
3
3
  "description": "Utilities for testing front-end components and applications",
4
4
  "type": "module",
5
- "version": "0.30.0",
5
+ "version": "0.31.0",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "eslint . --ext .js",
@@ -1,5 +1,5 @@
1
1
  import './vdiff.js';
2
2
 
3
- export { assert, aTimeout, defineCE, expect, html, nextFrame, oneEvent, waitUntil } from '@open-wc/testing';
3
+ export { assert, aTimeout, defineCE, expect, html, nextFrame, oneDefaultPreventedEvent, oneEvent, waitUntil } from '@open-wc/testing';
4
4
  export { clickAt, clickElem, focusElem, hoverAt, hoverElem, sendKeys, sendKeysElem } from './commands.js';
5
5
  export { fixture } from './fixture.js';
@@ -17,16 +17,21 @@ export function requestMouseReset() {
17
17
  shouldResetMouse = true;
18
18
  }
19
19
 
20
- export async function reset(opts) {
20
+ export async function reset(opts = {}) {
21
21
 
22
- opts = opts || {};
23
- opts.lang = opts.lang || DEFAULT_LANG;
24
- opts.mathjax = opts.mathjax || {};
22
+ const defaultOpts = {
23
+ lang: DEFAULT_LANG,
24
+ mathjax: {},
25
+ rtl: !!opts.lang?.startsWith('ar'),
26
+ viewport: {
27
+ height: DEFAULT_VIEWPORT_HEIGHT,
28
+ width: DEFAULT_VIEWPORT_WIDTH
29
+ }
30
+ };
31
+
32
+ opts = { ...defaultOpts, ...opts };
33
+ opts.viewport = { ...defaultOpts.viewport, ...opts.viewport };
25
34
  opts.mathjax.renderLatex = (typeof opts.mathjax.renderLatex === 'boolean') ? opts.mathjax.renderLatex : DEFAULT_MATHJAX_RENDER_LATEX;
26
- opts.rtl = opts.lang.startsWith('ar') || !!opts.rtl;
27
- opts.viewport = opts.viewport || {};
28
- opts.viewport.height = opts.viewport.height || DEFAULT_VIEWPORT_HEIGHT;
29
- opts.viewport.width = opts.viewport.width || DEFAULT_VIEWPORT_WIDTH;
30
35
 
31
36
  let awaitNextFrame = false;
32
37