shakapacker 8.2.0 → 8.4.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.
@@ -54,4 +54,44 @@ describe("Config", () => {
54
54
  resolve("app/javascript/manifest.json")
55
55
  )
56
56
  })
57
+
58
+ test("should have integrity disabled by default", () => {
59
+ const config = require("../../package/config")
60
+ expect(config.integrity.enabled).toBe(false)
61
+ })
62
+
63
+ test("should have sha384 as default hash function", () => {
64
+ const config = require("../../package/config")
65
+ expect(config.integrity.hash_functions).toStrictEqual(["sha384"])
66
+ })
67
+
68
+ test("should have anonymous as default crossorigin", () => {
69
+ const config = require("../../package/config")
70
+ expect(config.integrity.cross_origin).toBe("anonymous")
71
+ })
72
+
73
+ test("should allow enabling integrity", () => {
74
+ process.env.SHAKAPACKER_CONFIG = "config/shakapacker_integrity.yml"
75
+ const config = require("../../package/config")
76
+
77
+ expect(config.integrity.enabled).toBe(true)
78
+ })
79
+
80
+ test("should allow configuring hash functions", () => {
81
+ process.env.SHAKAPACKER_CONFIG = "config/shakapacker_integrity.yml"
82
+ const config = require("../../package/config")
83
+
84
+ expect(config.integrity.hash_functions).toStrictEqual([
85
+ "sha384",
86
+ "sha256",
87
+ "sha512"
88
+ ])
89
+ })
90
+
91
+ test("should allow configuring crossorigin", () => {
92
+ process.env.SHAKAPACKER_CONFIG = "config/shakapacker_integrity.yml"
93
+ const config = require("../../package/config")
94
+
95
+ expect(config.integrity.cross_origin).toBe("use-credentials")
96
+ })
57
97
  })