Skip to content

Commit

Permalink
Merge pull request #26 from abcnews/mock-pl-events
Browse files Browse the repository at this point in the history
Mock PL events dev convenience method
  • Loading branch information
drzax committed Nov 2, 2022
2 parents 186e398 + 61ded7c commit 86525a4
Show file tree
Hide file tree
Showing 7 changed files with 13,682 additions and 33,758 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,38 @@ requestDOMPermit('article').then(() => {
});
```

### Development utils

Sometimes developing locally for the PL environment is difficult due to the DOM permit system that `requestDOMPermit` provides an interface for as it relies on events fired by Presentation Layer and the existence of some specific DOM elements.

There is an additional function exported from the library — `mockDecoyActivationEvents` — which can be used to mock the decoy events and make testing using a local test page easier.

Example usage:

```js
import {
requestDOMPermit,
mockDecoyActivationEvents,
} from '@abcnews/env-utils';

if (process.env.NODE_ENV === 'development') {
mockDecoyActivationEvents();
}

requestDOMPermit('key').then(/* you have a permit for 'key' */);
```

You will also need to add the DOM requestDOMPermit expects for decoys to your testing HTML. For example, a ranged decoy with the key 'key':

```html
<div data-component="Decoy" data-key="key" data-clone="true">
<p>
All the stuff between here is inside the decoy and fair game after a DOM
permit is granted.
</p>
</div>
```

## API

### `APPLICATIONS`, `GENERATIONS`, & `TIERS`
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
Loading

0 comments on commit 86525a4

Please sign in to comment.