jest-webextension-mock 3.8.0 → 3.8.2

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.
@@ -10,23 +10,23 @@ jobs:
10
10
  name: Publish
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v2
14
- - name: Get yarn cache directory path
15
- id: yarn-cache-dir-path
16
- run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
17
- - uses: actions/cache@v2
18
- id: yarn-cache
19
- with:
20
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
21
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22
- restore-keys: ${{ runner.os }}-yarn-
23
- - name: Yarn Install
24
- run: yarn install
25
- - name: Yarn Test
26
- run: yarn test
27
- - name: Publish
28
- if: github.ref == 'refs/heads/main'
29
- uses: mikeal/merge-release@master
30
- env:
31
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
- NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
13
+ - uses: actions/checkout@v2
14
+ - name: Get yarn cache directory path
15
+ id: yarn-cache-dir-path
16
+ run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
17
+ - uses: actions/cache@v2
18
+ id: yarn-cache
19
+ with:
20
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
21
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22
+ restore-keys: ${{ runner.os }}-yarn-
23
+ - name: Yarn Install
24
+ run: yarn install
25
+ - name: Yarn Test
26
+ run: yarn test
27
+ - name: Publish
28
+ if: github.ref == 'refs/heads/main'
29
+ uses: mikeal/merge-release@master
30
+ env:
31
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
+ NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
@@ -2,34 +2,33 @@ name: Build and Test
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main ]
5
+ branches: [main]
6
6
  pull_request:
7
- branches: [ main ]
7
+ branches: [main]
8
8
 
9
9
  jobs:
10
10
  build:
11
-
12
11
  runs-on: ubuntu-latest
13
12
 
14
13
  strategy:
15
14
  matrix:
16
- node-version: [10.x, 12.x, 14.x]
15
+ node-version: [14.x, 16.x, 18.x]
17
16
 
18
17
  steps:
19
- - uses: actions/checkout@v2
20
- - name: Get yarn cache directory path
21
- id: yarn-cache-dir-path
22
- run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
23
- - uses: actions/cache@v2
24
- id: yarn-cache
25
- with:
26
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
27
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
28
- restore-keys: ${{ runner.os }}-yarn-
29
- - name: Use Node.js ${{ matrix.node-version }}
30
- uses: actions/setup-node@v1
31
- with:
32
- node-version: ${{ matrix.node-version }}
33
- - run: yarn install
34
- - run: yarn test
35
- - uses: codecov/codecov-action@v1
18
+ - uses: actions/checkout@v2
19
+ - name: Get yarn cache directory path
20
+ id: yarn-cache-dir-path
21
+ run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
22
+ - uses: actions/cache@v2
23
+ id: yarn-cache
24
+ with:
25
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
26
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
27
+ restore-keys: ${{ runner.os }}-yarn-
28
+ - name: Use Node.js ${{ matrix.node-version }}
29
+ uses: actions/setup-node@v1
30
+ with:
31
+ node-version: ${{ matrix.node-version }}
32
+ - run: yarn install
33
+ - run: yarn test
34
+ - uses: codecov/codecov-action@v1
package/dist/setup.js CHANGED
@@ -18,6 +18,7 @@ var omnibox = {
18
18
  };
19
19
 
20
20
  var onMessageListeners = [];
21
+ var onMessageExternalListeners = [];
21
22
  var runtime = {
22
23
  connect: jest.fn(function (_ref) {
23
24
  var name = _ref.name;
@@ -59,6 +60,19 @@ var runtime = {
59
60
  return onMessageListeners.includes(listener);
60
61
  })
61
62
  },
63
+ onMessageExternal: {
64
+ addListener: jest.fn(function (listener) {
65
+ onMessageExternalListeners.push(listener);
66
+ }),
67
+ removeListener: jest.fn(function (listener) {
68
+ onMessageExternalListeners = onMessageExternalListeners.filter(function (lstn) {
69
+ return lstn !== listener;
70
+ });
71
+ }),
72
+ hasListener: jest.fn(function (listener) {
73
+ return onMessageExternalListeners.includes(listener);
74
+ })
75
+ },
62
76
  onConnect: {
63
77
  addListener: jest.fn(),
64
78
  removeListener: jest.fn(),
@@ -72,13 +86,18 @@ var runtime = {
72
86
  getURL: jest.fn(function (path) {
73
87
  return path;
74
88
  }),
75
- openOptionsPage: jest.fn()
89
+ openOptionsPage: jest.fn(),
90
+ getManifest: jest.fn(function () {
91
+ return {
92
+ manifest_version: 3
93
+ };
94
+ })
76
95
  };
77
96
 
78
97
  // https://developer.chrome.com/extensions/tabs
79
98
  var tabs = {
80
99
  get: jest.fn(function () {
81
- var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { };
100
+ var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
82
101
  return cb({});
83
102
  }),
84
103
  getCurrent: jest.fn(function (cb) {
@@ -119,23 +138,23 @@ var tabs = {
119
138
  }),
120
139
  duplicate: jest.fn(function () {
121
140
  var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
122
- var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { };
141
+ var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
123
142
  return cb(Object.assign({}, {
124
143
  id: id
125
144
  }));
126
145
  }),
127
146
  query: jest.fn(function () {
128
- var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { };
147
+ var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
129
148
  return cb([{}]);
130
149
  }),
131
150
  highlight: jest.fn(function () {
132
- var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { };
151
+ var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
133
152
  return cb();
134
153
  }),
135
154
  update: jest.fn(function () {
136
155
  var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
137
156
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
138
- var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () { };
157
+ var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
139
158
  return cb(Object.assign({}, props, {
140
159
  id: id
141
160
  }));
@@ -143,7 +162,7 @@ var tabs = {
143
162
  move: jest.fn(function () {
144
163
  var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
145
164
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
146
- var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () { };
165
+ var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
147
166
  return cb(ids.map(function (id) {
148
167
  return Object.assign({}, props, {
149
168
  id: id
@@ -481,20 +500,46 @@ var extension = {
481
500
  getURL: jest.fn()
482
501
  };
483
502
 
503
+ var cbOrPromise$1 = function cbOrPromise(cb, value) {
504
+ if (cb !== undefined) {
505
+ return cb(value);
506
+ }
507
+
508
+ return Promise.resolve(value);
509
+ };
510
+
484
511
  var downloads = {
485
- acceptDanger: jest.fn((downloadId, cb) => cbOrPromise(cb)),
486
- cancel: jest.fn((downloadId, cb) => cbOrPromise(cb)),
487
- download: jest.fn((options, cb) => cbOrPromise(cb)),
488
- erase: jest.fn((query, cb) => cbOrPromise(cb)),
489
- getFileIcon: jest.fn((downloadId, cb) => cbOrPromise(cb)),
512
+ acceptDanger: jest.fn(function (downloadId, cb) {
513
+ return cbOrPromise$1(cb);
514
+ }),
515
+ cancel: jest.fn(function (downloadId, cb) {
516
+ return cbOrPromise$1(cb);
517
+ }),
518
+ download: jest.fn(function (options, cb) {
519
+ return cbOrPromise$1(cb);
520
+ }),
521
+ erase: jest.fn(function (query, cb) {
522
+ return cbOrPromise$1(cb);
523
+ }),
524
+ getFileIcon: jest.fn(function (downloadId, cb) {
525
+ return cbOrPromise$1(cb);
526
+ }),
490
527
  open: jest.fn(),
491
- pause: jest.fn((downloadId, cb) => cbOrPromise(cb)),
492
- removeFile: jest.fn((downloadId, cb) => cbOrPromise(cb)),
493
- resume: jest.fn((downloadId, cb) => cbOrPromise(cb)),
494
- search: jest.fn((query, cb) => cbOrPromise(cb)),
528
+ pause: jest.fn(function (downloadId, cb) {
529
+ return cbOrPromise$1(cb);
530
+ }),
531
+ removeFile: jest.fn(function (downloadId, cb) {
532
+ return cbOrPromise$1(cb);
533
+ }),
534
+ resume: jest.fn(function (downloadId, cb) {
535
+ return cbOrPromise$1(cb);
536
+ }),
537
+ search: jest.fn(function (query, cb) {
538
+ return cbOrPromise$1(cb);
539
+ }),
495
540
  setShelfEnabled: jest.fn(),
496
541
  show: jest.fn(),
497
- showDefaultFolder: jest.fn(),
542
+ showDefaultFolder: jest.fn()
498
543
  };
499
544
 
500
545
  var geckoProfiler = {
@@ -536,9 +581,9 @@ var chrome = {
536
581
  i18n: i18n,
537
582
  webNavigation: webNavigation,
538
583
  extension: extension,
539
- downloads: downloads,
584
+ downloads: downloads
540
585
  };
541
- // Firefox uses 'browser' but aliases it to chrome
586
+ // Firefox uses 'browser' but aliases it to chrome
542
587
 
543
588
  /**
544
589
  * This is a setup file we specify as our 'main' entry point
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-webextension-mock",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "description": "Mock the components of a WebExtension",
5
5
  "main": "dist/setup.js",
6
6
  "module": "src/setup.js",
@@ -44,5 +44,6 @@
44
44
  "setupFiles": [
45
45
  "./__setups__/chrome.js"
46
46
  ]
47
- }
47
+ },
48
+ "dependencies": {}
48
49
  }