@khanacademy/perseus-core 0.0.0-PR745-20231004184900 → 0.0.0-PR745-20231004195820

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @khanacademy/perseus-core
2
2
 
3
- ## 0.0.0-PR745-20231004184900
3
+ ## 0.0.0-PR745-20231004195820
4
4
 
5
5
  ### Patch Changes
6
6
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Shared Perseus infrastructure",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "0.0.0-PR745-20231004184900",
6
+ "version": "0.0.0-PR745-20231004195820",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -6,8 +6,12 @@ describe("add-library-version-to-perseus-debug", () => {
6
6
  });
7
7
 
8
8
  it("should add the given library to __perseus_debug__", () => {
9
+ // Array
10
+
11
+ // Act
9
12
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
10
13
 
14
+ // Assert
11
15
  expect(globalThis.__perseus_debug__).toMatchInlineSnapshot(`
12
16
  {
13
17
  "test-lib": "v1.0.0",
@@ -16,10 +20,14 @@ describe("add-library-version-to-perseus-debug", () => {
16
20
  });
17
21
 
18
22
  it("should extend __perseus_debug__ when multiple libraries registered", () => {
23
+ // Arrange
24
+
25
+ // Act
19
26
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
20
27
  addLibraryVersionToPerseusDebug("sample-lib", "2.0.0");
21
28
  addLibraryVersionToPerseusDebug("utility-lib", "3.0.0");
22
29
 
30
+ // Assert
23
31
  expect(globalThis.__perseus_debug__).toMatchInlineSnapshot(`
24
32
  {
25
33
  "sample-lib": "v2.0.0",
@@ -30,11 +38,16 @@ describe("add-library-version-to-perseus-debug", () => {
30
38
  });
31
39
 
32
40
  it("should convert library entry to array when multiple versions of the same library registered", () => {
41
+ // Arrange
42
+ jest.spyOn(console, "warn").mockImplementation();
43
+
44
+ // Act
33
45
  addLibraryVersionToPerseusDebug("test-lib", "1.0.1");
34
46
  addLibraryVersionToPerseusDebug("test-lib", "4.1.8");
35
47
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
36
48
  addLibraryVersionToPerseusDebug("test-lib", "2.0.0");
37
49
 
50
+ // Assert
38
51
  expect(globalThis.__perseus_debug__).toMatchInlineSnapshot(`
39
52
  {
40
53
  "test-lib": [
@@ -48,13 +61,16 @@ describe("add-library-version-to-perseus-debug", () => {
48
61
  });
49
62
 
50
63
  it("should warn when multiple versions of the same library registered", () => {
51
- const warnSpy = jest.spyOn(console, "warn");
64
+ // Arrange
65
+ const warnSpy = jest.spyOn(console, "warn").mockImplementation();
52
66
 
67
+ // Act
53
68
  addLibraryVersionToPerseusDebug("test-lib", "1.0.1");
54
69
  addLibraryVersionToPerseusDebug("test-lib", "4.1.8");
55
70
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
56
71
  addLibraryVersionToPerseusDebug("test-lib", "2.0.0");
57
72
 
73
+ // Assert
58
74
  expect(warnSpy).toHaveBeenCalledWith(
59
75
  expect.stringMatching(
60
76
  /Multiple versions of test-lib loaded on this page/,
@@ -63,10 +79,14 @@ describe("add-library-version-to-perseus-debug", () => {
63
79
  });
64
80
 
65
81
  it("should not register duplicates for duplicate calls of the same library and version", () => {
82
+ // Arrange
83
+
84
+ // Act
66
85
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
67
86
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
68
87
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
69
88
 
89
+ // Assert
70
90
  expect(globalThis.__perseus_debug__).toMatchInlineSnapshot(`
71
91
  {
72
92
  "test-lib": "v1.0.0",
@@ -75,12 +95,15 @@ describe("add-library-version-to-perseus-debug", () => {
75
95
  });
76
96
 
77
97
  it("should not warn for duplicate calls for a library of the same library and version", () => {
78
- const warnSpy = jest.spyOn(console, "warn");
98
+ // Arrange
99
+ const warnSpy = jest.spyOn(console, "warn").mockImplementation();
79
100
 
101
+ // Act
80
102
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
81
103
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
82
104
  addLibraryVersionToPerseusDebug("test-lib", "1.0.0");
83
105
 
106
+ // Assert
84
107
  expect(warnSpy).not.toHaveBeenCalled();
85
108
  });
86
109
  });