@learncard/partner-connect 0.4.2 → 0.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@learncard/partner-connect",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/learningeconomy/LearnCard"
@@ -27,8 +27,9 @@
27
27
  "build": "rollup -c",
28
28
  "dev": "rollup -c -w",
29
29
  "typecheck": "tsc --noEmit",
30
- "test": "jest -c jest.config.js",
31
- "test:watch": "jest -c jest.config.js --watch"
30
+ "test": "vitest run",
31
+ "test:watch": "vitest",
32
+ "test:coverage": "vitest run --coverage"
32
33
  },
33
34
  "keywords": [
34
35
  "learncard",
@@ -42,7 +43,7 @@
42
43
  "license": "MIT",
43
44
  "author": "Learning Economy Foundation (www.learningeconomy.io)",
44
45
  "dependencies": {
45
- "@learncard/types": "5.18.1"
46
+ "@learncard/types": "5.18.2"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@rollup/plugin-commonjs": "^22.0.2",
@@ -1,18 +1,23 @@
1
+ // @vitest-environment jsdom
2
+ import { vi } from 'vitest';
3
+
1
4
  /**
2
5
  * Tests for standalone mock mode and embed detection in
3
6
  * @learncard/partner-connect. These run in jsdom, where `window.self` equals
4
7
  * `window.top` (i.e. not embedded), so 'auto' mock mode is active by default.
5
8
  */
6
9
 
10
+ import type { MockInstance } from 'vitest';
11
+
7
12
  import { PartnerConnect, createPartnerConnect, isEmbedded } from './index';
8
13
 
9
14
  const flush = (): Promise<void> => new Promise(resolve => setTimeout(resolve, 0));
10
15
 
11
- let errorSpy: jest.SpyInstance;
16
+ let errorSpy: MockInstance;
12
17
 
13
18
  beforeEach(() => {
14
- jest.spyOn(console, 'log').mockImplementation(() => undefined);
15
- errorSpy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
19
+ vi.spyOn(console, 'log').mockImplementation(() => undefined);
20
+ errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
16
21
  try {
17
22
  localStorage.clear();
18
23
  } catch {
@@ -21,7 +26,7 @@ beforeEach(() => {
21
26
  });
22
27
 
23
28
  afterEach(() => {
24
- jest.restoreAllMocks();
29
+ vi.restoreAllMocks();
25
30
  document.querySelectorAll('.lc-mock-toast, .lc-mock-stack').forEach(node => node.remove());
26
31
  });
27
32
 
@@ -1,3 +1,4 @@
1
+ import { vi } from 'vitest';
1
2
  /**
2
3
  * Tests for the origin-resolution layer of @learncard/partner-connect.
3
4
  *
@@ -9,6 +10,8 @@
9
10
  * rejecting untrusted event origins at runtime.
10
11
  */
11
12
 
13
+ import type { MockInstance } from 'vitest';
14
+
12
15
  import { PartnerConnect } from './index';
13
16
 
14
17
  // ---------------------------------------------------------------------------
@@ -29,11 +32,7 @@ interface WindowOverrides {
29
32
  * actually reads.
30
33
  */
31
34
  function installLocation(overrides: WindowOverrides): void {
32
- const {
33
- search = '',
34
- origin = 'https://partner-app.example.com',
35
- ancestors = null,
36
- } = overrides;
35
+ const { search = '', origin = 'https://partner-app.example.com', ancestors = null } = overrides;
37
36
 
38
37
  const ancestorOrigins: DOMStringList | undefined =
39
38
  ancestors === null
@@ -76,15 +75,15 @@ function clearSessionStorage(): void {
76
75
  }
77
76
 
78
77
  // Silence expected log output from the SDK in passing tests.
79
- let consoleLogSpy: jest.SpyInstance;
80
- let consoleWarnSpy: jest.SpyInstance;
81
- let consoleErrorSpy: jest.SpyInstance;
78
+ let consoleLogSpy: MockInstance;
79
+ let consoleWarnSpy: MockInstance;
80
+ let consoleErrorSpy: MockInstance;
82
81
 
83
82
  beforeEach(() => {
84
83
  clearSessionStorage();
85
- consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
86
- consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
87
- consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
84
+ consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
85
+ consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
86
+ consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
88
87
  });
89
88
 
90
89
  afterEach(() => {