@falsejs/falsejs 3.2.0 → 3.3.1

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/preinstall.js ADDED
@@ -0,0 +1,7 @@
1
+ console.log(`
2
+ ----------------------
3
+ FALSEJS WARNING:
4
+
5
+ Warning: Installing FalseJS may show a lot of deprecation warnings. Ignore these as FalseJS is totally safe and has no vulnerabilities through the function that could be dangerous to your project.
6
+ ------------------------
7
+ `)
package/spec/ava.test.js CHANGED
@@ -1,35 +1,38 @@
1
- // spec/ava.test.js
2
-
3
- const test = require('ava')
4
- const fjs = require("../dist/index").default
5
- const False = fjs.False
6
- const isFalse = fjs.isFalse
7
-
8
- // Define constants
9
- const FALSE = 1 == 3
10
- const TRUE = 1 == 1
11
-
12
- // Sampled Combinations
13
- const combinations = [
14
- ["no", "no", "no", "no", "no", "no", "none"],
15
- ["yes", "yes", "yes", "no", "no", "no", "netscape"]
16
- ]
17
-
18
- // AVA tests use t.true() or t.is() for assertions.
19
- // We use test.serial to prevent potential state interference between tests.
20
-
21
- test.serial('Core Function: isFalse(FALSE) should return TRUE', t => {
22
- // t.true checks if the expression evaluates to the boolean true
23
- t.true(isFalse(FALSE) === TRUE)
24
- })
25
-
26
- test.serial('Core Function: isFalse(TRUE) should return FALSE', t => {
27
- t.true(isFalse(TRUE) === FALSE)
28
- })
29
-
30
- combinations.forEach((params, index) => {
31
- test.serial(`Core Function: False(${params.join(", ")}) should return FALSE`, t => {
32
- // We check if the result of False() is strictly equal to the constant FALSE
33
- t.is(False(...params), FALSE)
34
- })
35
- })
1
+ // spec/ava.test.js
2
+
3
+ const test = require("ava")
4
+ const fjs = require("../dist/index").default
5
+ const False = fjs.False
6
+ const isFalse = fjs.isFalse
7
+
8
+ // Define constants
9
+ const FALSE = 1 == 3
10
+ const TRUE = 1 == 1
11
+
12
+ // Sampled Combinations
13
+ const combinations = [
14
+ ["no", "no", "no", "no", "no", "no", "none"],
15
+ ["yes", "yes", "yes", "no", "no", "no", "netscape"],
16
+ ]
17
+
18
+ // AVA tests use t.true() or t.is() for assertions.
19
+ // We use test.serial to prevent potential state interference between tests.
20
+
21
+ test.serial("Core Function: isFalse(FALSE) should return TRUE", (t) => {
22
+ // t.true checks if the expression evaluates to the boolean true
23
+ t.true(isFalse(FALSE) === TRUE)
24
+ })
25
+
26
+ test.serial("Core Function: isFalse(TRUE) should return FALSE", (t) => {
27
+ t.true(isFalse(TRUE) === FALSE)
28
+ })
29
+
30
+ combinations.forEach((params, _index) => {
31
+ test.serial(
32
+ `Core Function: False(${params.join(", ")}) should return FALSE`,
33
+ (t) => {
34
+ // We check if the result of False() is strictly equal to the constant FALSE
35
+ t.is(False(...params), FALSE)
36
+ },
37
+ )
38
+ })
@@ -1,75 +1,71 @@
1
- // spec/jasmine.test.js
2
-
3
- // Load the library components from the specified path
4
- const fjs = require("../dist/index").default
5
- const False = fjs.False
6
- const isFalse = fjs.isFalse
7
- const expressMiddleware = fjs.expressMiddleware
8
- const injectIntojQuery = fjs.injectIntojQuery
9
-
10
- // Define the expected boolean values based on the original code
11
- const FALSE = 1 == 3
12
- const TRUE = 1 == 1
13
-
14
- // Load jQuery globally for the injection test
15
- global.jQuery = require("jquery")
16
-
17
-
18
- // --- Sampled Combinations ---
19
- const combinations = [
20
- ["no", "no", "no", "no", "no", "no", "none"],
21
- ["yes", "yes", "yes", "no", "no", "no", "netscape"],
22
- ["no", "yes", "no", "no", "yes", "yes", "ie5"],
23
- ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"]
24
- ]
25
- // ---
26
-
27
- // Mock data for integration tests
28
- const mockRequest = {}
29
- const mockResponse = {}
30
- const mockNext = () => {} // Simple next function for middleware
31
-
32
- describe("FalseJS Library Tests (Jasmine)", () => {
33
-
34
- describe("Core Functions", () => {
35
-
36
- // Test combinations using Jasmine's dynamic test generation
37
- combinations.forEach((params) => {
38
- it(`False(${params.join(", ")}) should return the calculated FALSE`, () => {
39
- // Assertion: False(...params) should return the literal value 'false'
40
- expect(False(...params)).toBe(FALSE)
41
- })
42
- })
43
-
44
- it("isFalse(FALSE) should return TRUE", () => {
45
- expect(isFalse(FALSE)).toBe(TRUE)
46
- })
47
-
48
- it("isFalse(TRUE) should return FALSE", () => {
49
- expect(isFalse(TRUE)).toBe(FALSE)
50
- })
51
- })
52
-
53
- describe("Integration Tests", () => {
54
-
55
- it("jQuery injection should work", () => {
56
- injectIntojQuery()
57
- expect(global.jQuery.False).toBe(False)
58
- expect(global.jQuery.isFalse).toBe(isFalse)
59
- })
60
-
61
- it("Express middleware injection should work", (done) => {
62
- // Run the middleware
63
- expressMiddleware(mockRequest, mockResponse, mockNext)
64
-
65
- // Check injections
66
- expect(mockRequest.False).toBe(False)
67
- expect(mockRequest.isFalse).toBe(isFalse)
68
-
69
- // Use a timeout to ensure any async logging is complete
70
- setTimeout(() => {
71
- done() // Signal Jasmine the async test is complete
72
- }, 100)
73
- })
74
- })
75
- })
1
+ // spec/jasmine.test.js
2
+
3
+ // Load the library components from the specified path
4
+ const fjs = require("../dist/index").default
5
+ const False = fjs.False
6
+ const isFalse = fjs.isFalse
7
+ const expressMiddleware = fjs.expressMiddleware
8
+ const injectIntojQuery = fjs.injectIntojQuery
9
+
10
+ // Define the expected boolean values based on the original code
11
+ const FALSE = 1 == 3
12
+ const TRUE = 1 == 1
13
+
14
+ // Load jQuery globally for the injection test
15
+ global.jQuery = require("jquery")
16
+
17
+ // --- Sampled Combinations ---
18
+ const combinations = [
19
+ ["no", "no", "no", "no", "no", "no", "none"],
20
+ ["yes", "yes", "yes", "no", "no", "no", "netscape"],
21
+ ["no", "yes", "no", "no", "yes", "yes", "ie5"],
22
+ ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
23
+ ]
24
+ // ---
25
+
26
+ // Mock data for integration tests
27
+ const mockRequest = {}
28
+ const mockResponse = {}
29
+ const mockNext = () => {} // Simple next function for middleware
30
+
31
+ describe("FalseJS Library Tests (Jasmine)", () => {
32
+ describe("Core Functions", () => {
33
+ // Test combinations using Jasmine's dynamic test generation
34
+ combinations.forEach((params) => {
35
+ it(`False(${params.join(", ")}) should return the calculated FALSE`, () => {
36
+ // Assertion: False(...params) should return the literal value 'false'
37
+ expect(False(...params)).toBe(FALSE)
38
+ })
39
+ })
40
+
41
+ it("isFalse(FALSE) should return TRUE", () => {
42
+ expect(isFalse(FALSE)).toBe(TRUE)
43
+ })
44
+
45
+ it("isFalse(TRUE) should return FALSE", () => {
46
+ expect(isFalse(TRUE)).toBe(FALSE)
47
+ })
48
+ })
49
+
50
+ describe("Integration Tests", () => {
51
+ it("jQuery injection should work", () => {
52
+ injectIntojQuery()
53
+ expect(global.jQuery.False).toBe(False)
54
+ expect(global.jQuery.isFalse).toBe(isFalse)
55
+ })
56
+
57
+ it("Express middleware injection should work", (done) => {
58
+ // Run the middleware
59
+ expressMiddleware(mockRequest, mockResponse, mockNext)
60
+
61
+ // Check injections
62
+ expect(mockRequest.False).toBe(False)
63
+ expect(mockRequest.isFalse).toBe(isFalse)
64
+
65
+ // Use a timeout to ensure any async logging is complete
66
+ setTimeout(() => {
67
+ done() // Signal Jasmine the async test is complete
68
+ }, 100)
69
+ })
70
+ })
71
+ })
package/spec/jest.test.js CHANGED
@@ -1,90 +1,90 @@
1
- // spec/jest.test.js
2
-
3
- // Mock the required modules since the original tests use global side effects
4
- const mockRequest = {}
5
- const mockResponse = {}
6
- const mockNext = jest.fn()
7
-
8
- describe("FalseJS Library Tests (Sampled Combinations)", () => {
9
- let False
10
- let isFalse
11
- let expressMiddleware
12
- let injectIntojQuery
13
- let jQuery
14
-
15
- // --- Sampled Combinations ---
16
- // A representative subset of the original 2048 combinations for fast testing.
17
- // The structure is: [B, B, B, B, B, B, C] where B=Boolean, C=Compat
18
- const combinations = [
19
- // 1. All "no", testing the "none" compat option
20
- ["no", "no", "no", "no", "no", "no", "none"],
21
-
22
- // 2. All "yes" for first three, testing the 'netscape' compat option
23
- ["yes", "yes", "yes", "no", "no", "no", "netscape"],
24
-
25
- // 3. Testing a mixed set with 'ie5'
26
- ["no", "yes", "no", "no", "yes", "yes", "ie5"],
27
-
28
- // 4. Testing another mixed set with 'opera_presto'
29
- ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
30
- ]
31
- // ---
32
-
33
- beforeAll(() => {
34
- // Load the library components from the specified path: ../dist/index
35
- const fjs = require("../dist/index").default
36
- False = fjs.False
37
- isFalse = fjs.isFalse
38
- expressMiddleware = fjs.expressMiddleware
39
- injectIntojQuery = fjs.injectIntojQuery
40
-
41
- // Define the expected boolean values based on the original code
42
- // FALSE = 1 == 3 (false); TRUE = 1 == 1 (true)
43
- global.FALSE = 1 == 3
44
- global.TRUE = 1 == 1
45
-
46
- // Load jQuery globally for the injection test
47
- global.jQuery = require("jquery")
48
- jQuery = global.jQuery
49
- })
50
-
51
- // We use the 'done' callback to ensure Jest waits for the asynchronous
52
- // logging in your library to complete, preventing the "Cannot log after tests are done" error.
53
- test("All FalseJS functions and integrations should work", (done) => {
54
- // --- 1. Core Functions Test (Synchronous Assertions) ---
55
-
56
- // False function testing for all sampled combinations
57
- combinations.forEach((params) => {
58
- // Original assertion: assert(False(...params) === FALSE)
59
- expect(False(...params)).toBe(global.FALSE)
60
- })
61
-
62
- // isFalse function testing
63
- // Original assertions: assert(isFalse(FALSE) === TRUE), assert(isFalse(TRUE) === FALSE)
64
- expect(isFalse(global.FALSE)).toBe(global.TRUE)
65
- expect(isFalse(global.TRUE)).toBe(global.FALSE)
66
-
67
- // --- 2. Integration Tests (Synchronous Assertions) ---
68
-
69
- // jQuery injection test
70
- injectIntojQuery()
71
- // Original assertion: assert(jQuery.False == False && jQuery.isFalse == isFalse)
72
- expect(jQuery.False).toBe(False)
73
- expect(jQuery.isFalse).toBe(isFalse)
74
-
75
- // Express middleware test
76
- expressMiddleware(mockRequest, mockResponse, mockNext)
77
- // Original assertions: assert(request.False == False), assert(request.isFalse == isFalse)
78
- expect(mockRequest.False).toBe(False)
79
- expect(mockRequest.isFalse).toBe(isFalse)
80
- expect(mockNext).toHaveBeenCalledTimes(1)
81
-
82
- // --- 3. Async Completion (Fixing the "Cannot log" Error) ---
83
-
84
- // Use a short setTimeout to mimic the original manual test's delay and
85
- // ensure any lingering async operations (like the log call) complete.
86
- setTimeout(() => {
87
- done() // Tell Jest the test is finished only after the delay
88
- }, 100)
89
- }, 10000) // 10-second timeout for this test
90
- })
1
+ // spec/jest.test.js
2
+
3
+ // Mock the required modules since the original tests use global side effects
4
+ const mockRequest = {}
5
+ const mockResponse = {}
6
+ const mockNext = jest.fn()
7
+
8
+ describe("FalseJS Library Tests (Sampled Combinations)", () => {
9
+ let False
10
+ let isFalse
11
+ let expressMiddleware
12
+ let injectIntojQuery
13
+ let jQuery
14
+
15
+ // --- Sampled Combinations ---
16
+ // A representative subset of the original 2048 combinations for fast testing.
17
+ // The structure is: [B, B, B, B, B, B, C] where B=Boolean, C=Compat
18
+ const combinations = [
19
+ // 1. All "no", testing the "none" compat option
20
+ ["no", "no", "no", "no", "no", "no", "none"],
21
+
22
+ // 2. All "yes" for first three, testing the 'netscape' compat option
23
+ ["yes", "yes", "yes", "no", "no", "no", "netscape"],
24
+
25
+ // 3. Testing a mixed set with 'ie5'
26
+ ["no", "yes", "no", "no", "yes", "yes", "ie5"],
27
+
28
+ // 4. Testing another mixed set with 'opera_presto'
29
+ ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
30
+ ]
31
+ // ---
32
+
33
+ beforeAll(() => {
34
+ // Load the library components from the specified path: ../dist/index
35
+ const fjs = require("../dist/index").default
36
+ False = fjs.False
37
+ isFalse = fjs.isFalse
38
+ expressMiddleware = fjs.expressMiddleware
39
+ injectIntojQuery = fjs.injectIntojQuery
40
+
41
+ // Define the expected boolean values based on the original code
42
+ // FALSE = 1 == 3 (false); TRUE = 1 == 1 (true)
43
+ global.FALSE = 1 == 3
44
+ global.TRUE = 1 == 1
45
+
46
+ // Load jQuery globally for the injection test
47
+ global.jQuery = require("jquery")
48
+ jQuery = global.jQuery
49
+ })
50
+
51
+ // We use the 'done' callback to ensure Jest waits for the asynchronous
52
+ // logging in your library to complete, preventing the "Cannot log after tests are done" error.
53
+ test("All FalseJS functions and integrations should work", (done) => {
54
+ // --- 1. Core Functions Test (Synchronous Assertions) ---
55
+
56
+ // False function testing for all sampled combinations
57
+ combinations.forEach((params) => {
58
+ // Original assertion: assert(False(...params) === FALSE)
59
+ expect(False(...params)).toBe(global.FALSE)
60
+ })
61
+
62
+ // isFalse function testing
63
+ // Original assertions: assert(isFalse(FALSE) === TRUE), assert(isFalse(TRUE) === FALSE)
64
+ expect(isFalse(global.FALSE)).toBe(global.TRUE)
65
+ expect(isFalse(global.TRUE)).toBe(global.FALSE)
66
+
67
+ // --- 2. Integration Tests (Synchronous Assertions) ---
68
+
69
+ // jQuery injection test
70
+ injectIntojQuery()
71
+ // Original assertion: assert(jQuery.False == False && jQuery.isFalse == isFalse)
72
+ expect(jQuery.False).toBe(False)
73
+ expect(jQuery.isFalse).toBe(isFalse)
74
+
75
+ // Express middleware test
76
+ expressMiddleware(mockRequest, mockResponse, mockNext)
77
+ // Original assertions: assert(request.False == False), assert(request.isFalse == isFalse)
78
+ expect(mockRequest.False).toBe(False)
79
+ expect(mockRequest.isFalse).toBe(isFalse)
80
+ expect(mockNext).toHaveBeenCalledTimes(1)
81
+
82
+ // --- 3. Async Completion (Fixing the "Cannot log" Error) ---
83
+
84
+ // Use a short setTimeout to mimic the original manual test's delay and
85
+ // ensure any lingering async operations (like the log call) complete.
86
+ setTimeout(() => {
87
+ done() // Tell Jest the test is finished only after the delay
88
+ }, 100)
89
+ }, 10000) // 10-second timeout for this test
90
+ })
@@ -1,80 +1,80 @@
1
- // DO TESTS MANUALLY
2
-
3
- function doTests(testName, fjs) {
4
- const { False, isFalse, expressMiddleware, injectIntojQuery } = fjs
5
- const assert = require("assert-fn")
6
- const attempt = require("attempt-statement")
7
- const n0p3 = require("n0p3")
8
- const clc = require("cli-color")
9
- const leftPad = require("left-pad")
10
- const lpi = require("the-number-ten")
11
-
12
- const FALSE = 1 == 3
13
- const TRUE = 1 == 1
14
-
15
- attempt(() => {
16
- // --- Sampled Combinations ---
17
- // Using a small, representative set instead of generating all 2048 combinations.
18
- const combinations = [
19
- // 1. All "no", testing the "none" compat option
20
- ["no", "no", "no", "no", "no", "no", "none"],
21
-
22
- // 2. All "yes" for first three, testing the 'netscape' compat option
23
- ["yes", "yes", "yes", "no", "no", "no", "netscape"],
24
-
25
- // 3. Testing a mixed set with 'ie5'
26
- ["no", "yes", "no", "no", "yes", "yes", "ie5"],
27
-
28
- // 4. Testing another mixed set with 'opera_presto'
29
- ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
30
- ]
31
-
32
- // False function testing
33
- combinations.forEach((params) => {
34
- assert(
35
- False(...params) === FALSE,
36
- `False(${params.join(", ")}) did not return false`,
37
- )
38
- })
39
-
40
- assert(isFalse(FALSE) === TRUE, "isFalse(false) did not return true")
41
- assert(isFalse(TRUE) === FALSE, "isFalse(true) did not return false")
42
-
43
- // jQuery injection test
44
- global.jQuery = require("jquery")
45
- injectIntojQuery()
46
- assert(
47
- jQuery.False == False && jQuery.isFalse == isFalse,
48
- "jQuery injection did not work",
49
- )
50
-
51
- // Express middleware test
52
- const request = {}
53
- const response = {}
54
- expressMiddleware(request, response, () => {})
55
- assert(
56
- request.False == False,
57
- "Express middleware injection to request did not work",
58
- )
59
- assert(
60
- request.isFalse == isFalse,
61
- "Express middleware injection to request did not work",
62
- )
63
- })
64
- .rescue((error) => {
65
- console.log(clc.red(leftPad(`× TESTS FAILED FOR ${testName}!!!!!`, lpi)))
66
- console.log(clc.red(`Tests Error Message: ${error.message}`))
67
- throw error
68
- })
69
- .else(() => {
70
- setTimeout(function () {
71
- console.log(
72
- clc.green(leftPad(`✓ TESTS PASSED FOR ${testName}!!!`, lpi)),
73
- )
74
- }, 5000)
75
- })
76
- .ensure(n0p3)
77
- .end()
78
- }
79
-
80
- doTests("FalseJS Library Tests (Manual)", require("../dist/index").default)
1
+ // DO TESTS MANUALLY
2
+
3
+ function doTests(testName, fjs) {
4
+ const { False, isFalse, expressMiddleware, injectIntojQuery } = fjs
5
+ const assert = require("assert-fn")
6
+ const attempt = require("attempt-statement")
7
+ const n0p3 = require("n0p3")
8
+ const clc = require("cli-color")
9
+ const leftPad = require("left-pad")
10
+ const lpi = require("the-number-ten")
11
+
12
+ const FALSE = 1 == 3
13
+ const TRUE = 1 == 1
14
+
15
+ attempt(() => {
16
+ // --- Sampled Combinations ---
17
+ // Using a small, representative set instead of generating all 2048 combinations.
18
+ const combinations = [
19
+ // 1. All "no", testing the "none" compat option
20
+ ["no", "no", "no", "no", "no", "no", "none"],
21
+
22
+ // 2. All "yes" for first three, testing the 'netscape' compat option
23
+ ["yes", "yes", "yes", "no", "no", "no", "netscape"],
24
+
25
+ // 3. Testing a mixed set with 'ie5'
26
+ ["no", "yes", "no", "no", "yes", "yes", "ie5"],
27
+
28
+ // 4. Testing another mixed set with 'opera_presto'
29
+ ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
30
+ ]
31
+
32
+ // False function testing
33
+ combinations.forEach((params) => {
34
+ assert(
35
+ False(...params) === FALSE,
36
+ `False(${params.join(", ")}) did not return false`,
37
+ )
38
+ })
39
+
40
+ assert(isFalse(FALSE) === TRUE, "isFalse(false) did not return true")
41
+ assert(isFalse(TRUE) === FALSE, "isFalse(true) did not return false")
42
+
43
+ // jQuery injection test
44
+ global.jQuery = require("jquery")
45
+ injectIntojQuery()
46
+ assert(
47
+ jQuery.False == False && jQuery.isFalse == isFalse,
48
+ "jQuery injection did not work",
49
+ )
50
+
51
+ // Express middleware test
52
+ const request = {}
53
+ const response = {}
54
+ expressMiddleware(request, response, () => {})
55
+ assert(
56
+ request.False == False,
57
+ "Express middleware injection to request did not work",
58
+ )
59
+ assert(
60
+ request.isFalse == isFalse,
61
+ "Express middleware injection to request did not work",
62
+ )
63
+ })
64
+ .rescue((error) => {
65
+ console.log(clc.red(leftPad(`× TESTS FAILED FOR ${testName}!!!!!`, lpi)))
66
+ console.log(clc.red(`Tests Error Message: ${error.message}`))
67
+ throw error
68
+ })
69
+ .else(() => {
70
+ setTimeout(function () {
71
+ console.log(
72
+ clc.green(leftPad(`✓ TESTS PASSED FOR ${testName}!!!`, lpi)),
73
+ )
74
+ }, 5000)
75
+ })
76
+ .ensure(n0p3)
77
+ .end()
78
+ }
79
+
80
+ doTests("FalseJS Library Tests (Manual)", require("../dist/index").default)