@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.
@@ -1,73 +1,73 @@
1
- // spec/mocha.test.js
2
-
3
- const { expect } = require("chai")
4
-
5
- const fjs = require("../dist/index").default
6
- const False = fjs.False
7
- const isFalse = fjs.isFalse
8
- const expressMiddleware = fjs.expressMiddleware
9
- const injectIntojQuery = fjs.injectIntojQuery
10
-
11
- // Define the expected boolean values based on the original code
12
- const FALSE = 1 == 3
13
- const TRUE = 1 == 1
14
-
15
- // Load jQuery globally for the injection test
16
- global.jQuery = require("jquery")
17
-
18
- // --- Sampled Combinations ---
19
- // The same small, representative set for fast testing.
20
- const combinations = [
21
- ["no", "no", "no", "no", "no", "no", "none"],
22
- ["yes", "yes", "yes", "no", "no", "no", "netscape"],
23
- ["no", "yes", "no", "no", "yes", "yes", "ie5"],
24
- ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
25
- ]
26
- // ---
27
-
28
- // Mock data for integration tests
29
- const mockRequest = {}
30
- const mockResponse = {}
31
- const mockNext = () => {} // Simple next function for middleware
32
-
33
- describe("FalseJS Library Tests (Mocha)", function () {
34
- describe("Core Functions", function () {
35
- // Test combinations using Mocha's dynamic test generation
36
- combinations.forEach((params, index) => {
37
- it(`Combination ${index + 1}: False(${params.join(", ")}) should return FALSE`, function () {
38
- // Assertion: False(...params) should return the literal value 'false'
39
- expect(False(...params)).to.equal(FALSE)
40
- })
41
- })
42
-
43
- it("isFalse(FALSE) should return TRUE", function () {
44
- expect(isFalse(FALSE)).to.equal(TRUE)
45
- })
46
-
47
- it("isFalse(TRUE) should return FALSE", function () {
48
- expect(isFalse(TRUE)).to.equal(FALSE)
49
- })
50
- })
51
-
52
- describe("Integration Tests", function () {
53
- it("jQuery injection should work", function () {
54
- injectIntojQuery()
55
- expect(global.jQuery.False).to.equal(False)
56
- expect(global.jQuery.isFalse).to.equal(isFalse)
57
- })
58
-
59
- it("Express middleware injection should work", function (done) {
60
- // Run the middleware
61
- expressMiddleware(mockRequest, mockResponse, mockNext)
62
-
63
- // Check injections
64
- expect(mockRequest.False).to.equal(False)
65
- expect(mockRequest.isFalse).to.equal(isFalse)
66
-
67
- // Use a timeout to ensure any async logging is complete, similar to Jest/Manual
68
- setTimeout(() => {
69
- done() // Signal Mocha the async test is complete
70
- }, 100)
71
- }).timeout(10000) // Set a high timeout for async stability
72
- })
73
- })
1
+ // spec/mocha.test.js
2
+
3
+ const { expect } = require("chai")
4
+
5
+ const fjs = require("../dist/index").default
6
+ const False = fjs.False
7
+ const isFalse = fjs.isFalse
8
+ const expressMiddleware = fjs.expressMiddleware
9
+ const injectIntojQuery = fjs.injectIntojQuery
10
+
11
+ // Define the expected boolean values based on the original code
12
+ const FALSE = 1 == 3
13
+ const TRUE = 1 == 1
14
+
15
+ // Load jQuery globally for the injection test
16
+ global.jQuery = require("jquery")
17
+
18
+ // --- Sampled Combinations ---
19
+ // The same small, representative set for fast testing.
20
+ const combinations = [
21
+ ["no", "no", "no", "no", "no", "no", "none"],
22
+ ["yes", "yes", "yes", "no", "no", "no", "netscape"],
23
+ ["no", "yes", "no", "no", "yes", "yes", "ie5"],
24
+ ["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
25
+ ]
26
+ // ---
27
+
28
+ // Mock data for integration tests
29
+ const mockRequest = {}
30
+ const mockResponse = {}
31
+ const mockNext = () => {} // Simple next function for middleware
32
+
33
+ describe("FalseJS Library Tests (Mocha)", function () {
34
+ describe("Core Functions", function () {
35
+ // Test combinations using Mocha's dynamic test generation
36
+ combinations.forEach((params, index) => {
37
+ it(`Combination ${index + 1}: False(${params.join(", ")}) should return FALSE`, function () {
38
+ // Assertion: False(...params) should return the literal value 'false'
39
+ expect(False(...params)).to.equal(FALSE)
40
+ })
41
+ })
42
+
43
+ it("isFalse(FALSE) should return TRUE", function () {
44
+ expect(isFalse(FALSE)).to.equal(TRUE)
45
+ })
46
+
47
+ it("isFalse(TRUE) should return FALSE", function () {
48
+ expect(isFalse(TRUE)).to.equal(FALSE)
49
+ })
50
+ })
51
+
52
+ describe("Integration Tests", function () {
53
+ it("jQuery injection should work", function () {
54
+ injectIntojQuery()
55
+ expect(global.jQuery.False).to.equal(False)
56
+ expect(global.jQuery.isFalse).to.equal(isFalse)
57
+ })
58
+
59
+ it("Express middleware injection should work", function (done) {
60
+ // Run the middleware
61
+ expressMiddleware(mockRequest, mockResponse, mockNext)
62
+
63
+ // Check injections
64
+ expect(mockRequest.False).to.equal(False)
65
+ expect(mockRequest.isFalse).to.equal(isFalse)
66
+
67
+ // Use a timeout to ensure any async logging is complete, similar to Jest/Manual
68
+ setTimeout(() => {
69
+ done() // Signal Mocha the async test is complete
70
+ }, 100)
71
+ }).timeout(10000) // Set a high timeout for async stability
72
+ })
73
+ })
@@ -1,34 +1,44 @@
1
- // spec/qunit.test.js
2
-
3
- const QUnit = require('qunit')
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
- QUnit.module('FalseJS Library Tests (QUnit)', function(hooks) {
19
-
20
- QUnit.test('Core Function: isFalse(FALSE) should return TRUE', function(assert) {
21
- assert.true(isFalse(FALSE) === TRUE, 'isFalse(false) must return true')
22
- })
23
-
24
- QUnit.test('Core Function: isFalse(TRUE) should return FALSE', function(assert) {
25
- assert.true(isFalse(TRUE) === FALSE, 'isFalse(true) must return false')
26
- })
27
-
28
- combinations.forEach((params) => {
29
- QUnit.test(`Core Function: False(${params.join(", ")}) should return FALSE`, function(assert) {
30
- assert.true(False(...params) === FALSE, `False() must return false for params: ${params.join(", ")}`)
31
- })
32
- })
33
-
34
- })
1
+ // spec/qunit.test.js
2
+
3
+ const QUnit = require("qunit")
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
+ QUnit.module("FalseJS Library Tests (QUnit)", function (_hooks) {
19
+ QUnit.test(
20
+ "Core Function: isFalse(FALSE) should return TRUE",
21
+ function (assert) {
22
+ assert.true(isFalse(FALSE) === TRUE, "isFalse(false) must return true")
23
+ },
24
+ )
25
+
26
+ QUnit.test(
27
+ "Core Function: isFalse(TRUE) should return FALSE",
28
+ function (assert) {
29
+ assert.true(isFalse(TRUE) === FALSE, "isFalse(true) must return false")
30
+ },
31
+ )
32
+
33
+ combinations.forEach((params) => {
34
+ QUnit.test(
35
+ `Core Function: False(${params.join(", ")}) should return FALSE`,
36
+ function (assert) {
37
+ assert.true(
38
+ False(...params) === FALSE,
39
+ `False() must return false for params: ${params.join(", ")}`,
40
+ )
41
+ },
42
+ )
43
+ })
44
+ })
@@ -1,171 +1,182 @@
1
- // run_all_tests.js
2
-
3
- const { execSync } = require('node:child_process')
4
- const fs = require('node:fs')
5
- const path = require('node:path')
6
- const clc = require('cli-color')
7
-
8
- // --- Commands and Paths ---
9
- const JEST_COMMAND = 'npx jest spec/jest.test.js'
10
- const MOCHA_COMMAND = 'npx mocha spec/mocha.test.js'
11
- const JASMINE_COMMAND = 'npx jasmine spec/jasmine.test.js'
12
- const AVA_COMMAND = 'npx ava spec/ava.test.js'
13
- const QUNIT_COMMAND = 'node spec/qunit.test.js'
14
- const TAPE_COMMAND = 'node spec/tape.test.js'
15
- const MANUAL_COMMAND = 'node spec/manual.test.js'
16
- // INTERN_COMMAND has been removed
17
- const OUTPUT_DIR = '.falsejs'
18
- const OUTPUT_FILE = path.join(OUTPUT_DIR, 'test-log.txt')
19
-
20
- let outputLog = ''
21
- let jestPassed = false
22
- let mochaPassed = false
23
- let jasminePassed = false
24
- let avaPassed = false
25
- let qunitPassed = false
26
- let tapePassed = false
27
- // internPassed flag removed
28
- let manualPassed = false
29
- let allPassed = false
30
-
31
- const log = (message, colorFn = clc.white) => {
32
- console.log(colorFn(message))
33
- outputLog += message + '\n'
34
- }
35
-
36
- function runCommand(command) {
37
- try {
38
- const output = execSync(command, { encoding: 'utf8', stdio: 'pipe' })
39
- return { success: true, output }
40
- } catch (error) {
41
- const errorOutput = (error.stdout || '') + (error.stderr || '')
42
- return { success: false, output: errorOutput }
43
- }
44
- }
45
-
46
- // --- Test Execution ---
47
-
48
- log('--- Starting Comprehensive Test Suite (7 Suites) ---', clc.yellow)
49
-
50
-
51
- // 1. Run Manual Tests (First)
52
- // -----------------------------------------------------------------------------
53
- log('\n>> Running Manual Test (spec/manual.test.js)...', clc.cyan)
54
- const manualResult = runCommand(MANUAL_COMMAND)
55
- outputLog += manualResult.output
56
-
57
- if (manualResult.success && manualResult.output.includes('✓ TESTS PASSED')) {
58
- manualPassed = true
59
- log('✓ MANUAL TESTS PASSED.', clc.green)
60
- } else {
61
- log('× MANUAL TESTS FAILED (Exit Code Error).', clc.red)
62
- }
63
-
64
- // 2. Run Jest Tests (Second)
65
- // -----------------------------------------------------------------------------
66
- log('\n>> Running Jest Test (spec/jest.test.js)...', clc.cyan)
67
- const jestResult = runCommand(JEST_COMMAND)
68
- outputLog += jestResult.output
69
-
70
- if (jestResult.success) {
71
- jestPassed = true
72
- log('✓ JEST TESTS PASSED.', clc.green)
73
- } else {
74
- log('× JEST TESTS FAILED.', clc.red)
75
- }
76
-
77
- // 3. Run Tape Tests (Third)
78
- // -----------------------------------------------------------------------------
79
- log('\n>> Running Tape Test (spec/tape.test.js)...', clc.cyan)
80
- const tapeResult = runCommand(TAPE_COMMAND)
81
- outputLog += tapeResult.output
82
-
83
- if (tapeResult.success && !tapeResult.output.includes('not ok')) {
84
- tapePassed = true
85
- log('✓ TAPE TESTS PASSED.', clc.green)
86
- } else {
87
- log('× TAPE TESTS FAILED.', clc.red)
88
- }
89
-
90
- // 4. Run Mocha Tests (Fourth)
91
- // -----------------------------------------------------------------------------
92
- log('\n>> Running Mocha Test (spec/mocha.test.js)...', clc.cyan)
93
- const mochaResult = runCommand(MOCHA_COMMAND)
94
- outputLog += mochaResult.output
95
-
96
- if (mochaResult.success) {
97
- mochaPassed = true
98
- log('✓ MOCHA TESTS PASSED.', clc.green)
99
- } else {
100
- log('× MOCHA TESTS FAILED.', clc.red)
101
- }
102
-
103
- // 5. Run Jasmine Tests (Fifth)
104
- // -----------------------------------------------------------------------------
105
- log('\n>> Running Jasmine Test (spec/jasmine.test.js)...', clc.cyan)
106
- const jasmineResult = runCommand(JASMINE_COMMAND)
107
- outputLog += jasmineResult.output
108
-
109
- if (jasmineResult.success) {
110
- jasminePassed = true
111
- log('✓ JASMINE TESTS PASSED.', clc.green)
112
- } else {
113
- log('× JASMINE TESTS FAILED.', clc.red)
114
- }
115
-
116
- // 6. Run AVA Tests (Sixth)
117
- // -----------------------------------------------------------------------------
118
- log('\n>> Running AVA Test (spec/ava.test.js)...', clc.cyan)
119
- const avaResult = runCommand(AVA_COMMAND)
120
- outputLog += avaResult.output
121
-
122
- if (avaResult.success) {
123
- avaPassed = true
124
- log('✓ AVA TESTS PASSED.', clc.green)
125
- } else {
126
- log('× AVA TESTS FAILED.', clc.red)
127
- }
128
-
129
- // 7. Run QUnit Tests (Seventh)
130
- // -----------------------------------------------------------------------------
131
- log('\n>> Running QUnit Test (spec/qunit.test.js)...', clc.cyan)
132
- const qunitResult = runCommand(QUNIT_COMMAND)
133
- outputLog += qunitResult.output
134
-
135
- if (qunitResult.success && !qunitResult.output.includes('failed: 0')) {
136
- qunitPassed = true
137
- log('✓ QUNIT TESTS PASSED.', clc.green)
138
- } else if (qunitResult.success && qunitResult.output.includes('failed: 0')) {
139
- qunitPassed = true
140
- log('✓ QUNIT TESTS PASSED.', clc.green)
141
- } else {
142
- log('× QUNIT TESTS FAILED.', clc.red)
143
- }
144
-
145
-
146
- // 8. Final Result Summary
147
- // -----------------------------------------------------------------------------
148
- log('\n--- Final Test Suite Result ---', clc.yellow)
149
-
150
- if (jestPassed && mochaPassed && jasminePassed && manualPassed && avaPassed && qunitPassed && tapePassed) {
151
- allPassed = true
152
- log(' ALL 7 TEST SUITES PASSED SUCCESSFULLY! ', clc.bgGreen.bold)
153
- } else {
154
- log(' 1 or more TEST SUITES FAILED. Check logs above and in test-log.txt. ', clc.bgRed.bold)
155
- }
156
-
157
- // 9. Output to File and Exit
158
- // -----------------------------------------------------------------------------
159
- try {
160
- if (!fs.existsSync(OUTPUT_DIR)) {
161
- fs.mkdirSync(OUTPUT_DIR)
162
- }
163
- fs.writeFileSync(OUTPUT_FILE, outputLog)
164
- console.log(clc.yellow(`\nTest results written to ${OUTPUT_FILE}`))
165
- } catch {
166
- console.error(clc.red('\nERROR: Could not write test results to output file.'))
167
- }
168
-
169
- if (!allPassed) {
170
- process.exit(1)
171
- }
1
+ // run_all_tests.js
2
+
3
+ const { execSync } = require("node:child_process")
4
+ const fs = require("node:fs")
5
+ const path = require("node:path")
6
+ const clc = require("cli-color")
7
+
8
+ // --- Commands and Paths ---
9
+ const JEST_COMMAND = "npx jest spec/jest.test.js"
10
+ const MOCHA_COMMAND = "npx mocha spec/mocha.test.js"
11
+ const JASMINE_COMMAND = "npx jasmine spec/jasmine.test.js"
12
+ const AVA_COMMAND = "npx ava spec/ava.test.js"
13
+ const QUNIT_COMMAND = "node spec/qunit.test.js"
14
+ const TAPE_COMMAND = "node spec/tape.test.js"
15
+ const MANUAL_COMMAND = "node spec/manual.test.js"
16
+ // INTERN_COMMAND has been removed
17
+ const OUTPUT_DIR = ".falsejs"
18
+ const OUTPUT_FILE = path.join(OUTPUT_DIR, "test-log.txt")
19
+
20
+ let outputLog = ""
21
+ let jestPassed = false
22
+ let mochaPassed = false
23
+ let jasminePassed = false
24
+ let avaPassed = false
25
+ let qunitPassed = false
26
+ let tapePassed = false
27
+ // internPassed flag removed
28
+ let manualPassed = false
29
+ let allPassed = false
30
+
31
+ const log = (message, colorFn = clc.white) => {
32
+ console.log(colorFn(message))
33
+ outputLog += `${message}\n`
34
+ }
35
+
36
+ function runCommand(command) {
37
+ try {
38
+ const output = execSync(command, { encoding: "utf8", stdio: "pipe" })
39
+ return { success: true, output }
40
+ } catch (error) {
41
+ const errorOutput = (error.stdout || "") + (error.stderr || "")
42
+ return { success: false, output: errorOutput }
43
+ }
44
+ }
45
+
46
+ // --- Test Execution ---
47
+
48
+ log("--- Starting Comprehensive Test Suite (7 Suites) ---", clc.yellow)
49
+
50
+ // 1. Run Manual Tests (First)
51
+ // -----------------------------------------------------------------------------
52
+ log("\n>> Running Manual Test (spec/manual.test.js)...", clc.cyan)
53
+ const manualResult = runCommand(MANUAL_COMMAND)
54
+ outputLog += manualResult.output
55
+
56
+ if (manualResult.success && manualResult.output.includes("✓ TESTS PASSED")) {
57
+ manualPassed = true
58
+ log("✓ MANUAL TESTS PASSED.", clc.green)
59
+ } else {
60
+ log("× MANUAL TESTS FAILED (Exit Code Error).", clc.red)
61
+ }
62
+
63
+ // 2. Run Jest Tests (Second)
64
+ // -----------------------------------------------------------------------------
65
+ log("\n>> Running Jest Test (spec/jest.test.js)...", clc.cyan)
66
+ const jestResult = runCommand(JEST_COMMAND)
67
+ outputLog += jestResult.output
68
+
69
+ if (jestResult.success) {
70
+ jestPassed = true
71
+ log("✓ JEST TESTS PASSED.", clc.green)
72
+ } else {
73
+ log("× JEST TESTS FAILED.", clc.red)
74
+ }
75
+
76
+ // 3. Run Tape Tests (Third)
77
+ // -----------------------------------------------------------------------------
78
+ log("\n>> Running Tape Test (spec/tape.test.js)...", clc.cyan)
79
+ const tapeResult = runCommand(TAPE_COMMAND)
80
+ outputLog += tapeResult.output
81
+
82
+ if (tapeResult.success && !tapeResult.output.includes("not ok")) {
83
+ tapePassed = true
84
+ log("✓ TAPE TESTS PASSED.", clc.green)
85
+ } else {
86
+ log("× TAPE TESTS FAILED.", clc.red)
87
+ }
88
+
89
+ // 4. Run Mocha Tests (Fourth)
90
+ // -----------------------------------------------------------------------------
91
+ log("\n>> Running Mocha Test (spec/mocha.test.js)...", clc.cyan)
92
+ const mochaResult = runCommand(MOCHA_COMMAND)
93
+ outputLog += mochaResult.output
94
+
95
+ if (mochaResult.success) {
96
+ mochaPassed = true
97
+ log("✓ MOCHA TESTS PASSED.", clc.green)
98
+ } else {
99
+ log("× MOCHA TESTS FAILED.", clc.red)
100
+ }
101
+
102
+ // 5. Run Jasmine Tests (Fifth)
103
+ // -----------------------------------------------------------------------------
104
+ log("\n>> Running Jasmine Test (spec/jasmine.test.js)...", clc.cyan)
105
+ const jasmineResult = runCommand(JASMINE_COMMAND)
106
+ outputLog += jasmineResult.output
107
+
108
+ if (jasmineResult.success) {
109
+ jasminePassed = true
110
+ log("✓ JASMINE TESTS PASSED.", clc.green)
111
+ } else {
112
+ log("× JASMINE TESTS FAILED.", clc.red)
113
+ }
114
+
115
+ // 6. Run AVA Tests (Sixth)
116
+ // -----------------------------------------------------------------------------
117
+ log("\n>> Running AVA Test (spec/ava.test.js)...", clc.cyan)
118
+ const avaResult = runCommand(AVA_COMMAND)
119
+ outputLog += avaResult.output
120
+
121
+ if (avaResult.success) {
122
+ avaPassed = true
123
+ log("✓ AVA TESTS PASSED.", clc.green)
124
+ } else {
125
+ log("× AVA TESTS FAILED.", clc.red)
126
+ }
127
+
128
+ // 7. Run QUnit Tests (Seventh)
129
+ // -----------------------------------------------------------------------------
130
+ log("\n>> Running QUnit Test (spec/qunit.test.js)...", clc.cyan)
131
+ const qunitResult = runCommand(QUNIT_COMMAND)
132
+ outputLog += qunitResult.output
133
+
134
+ if (qunitResult.success && !qunitResult.output.includes("failed: 0")) {
135
+ qunitPassed = true
136
+ log("✓ QUNIT TESTS PASSED.", clc.green)
137
+ } else if (qunitResult.success && qunitResult.output.includes("failed: 0")) {
138
+ qunitPassed = true
139
+ log("✓ QUNIT TESTS PASSED.", clc.green)
140
+ } else {
141
+ log("× QUNIT TESTS FAILED.", clc.red)
142
+ }
143
+
144
+ // 8. Final Result Summary
145
+ // -----------------------------------------------------------------------------
146
+ log("\n--- Final Test Suite Result ---", clc.yellow)
147
+
148
+ if (
149
+ jestPassed &&
150
+ mochaPassed &&
151
+ jasminePassed &&
152
+ manualPassed &&
153
+ avaPassed &&
154
+ qunitPassed &&
155
+ tapePassed
156
+ ) {
157
+ allPassed = true
158
+ log(" ALL 7 TEST SUITES PASSED SUCCESSFULLY! ", clc.bgGreen.bold)
159
+ } else {
160
+ log(
161
+ " 1 or more TEST SUITES FAILED. Check logs above and in test-log.txt. ",
162
+ clc.bgRed.bold,
163
+ )
164
+ }
165
+
166
+ // 9. Output to File and Exit
167
+ // -----------------------------------------------------------------------------
168
+ try {
169
+ if (!fs.existsSync(OUTPUT_DIR)) {
170
+ fs.mkdirSync(OUTPUT_DIR)
171
+ }
172
+ fs.writeFileSync(OUTPUT_FILE, outputLog)
173
+ console.log(clc.yellow(`\nTest results written to ${OUTPUT_FILE}`))
174
+ } catch {
175
+ console.error(
176
+ clc.red("\nERROR: Could not write test results to output file."),
177
+ )
178
+ }
179
+
180
+ if (!allPassed) {
181
+ process.exit(1)
182
+ }
package/spec/tape.test.js CHANGED
@@ -1,33 +1,37 @@
1
- // spec/tape.test.js
2
-
3
- const test = require('tape')
4
-
5
- // Load the library components from the specified path
6
- const fjs = require("../dist/index").default
7
- const False = fjs.False
8
- const isFalse = fjs.isFalse
9
-
10
- // Define constants
11
- const FALSE = 1 == 3
12
- const TRUE = 1 == 1
13
-
14
- // Sampled Combinations
15
- const combinations = [
16
- ["no", "no", "no", "no", "no", "no", "none"],
17
- ["yes", "yes", "yes", "no", "no", "no", "netscape"]
18
- ]
19
-
20
- // Tape uses the 't' object for assertions (t.equal, t.ok, t.plan)
21
-
22
- test('FalseJS Core Functions', function (t) {
23
- // Plan the number of assertions expected in this main block (2 assertions + 2 combination blocks * 2 assertions each)
24
- t.plan(2 + combinations.length)
25
-
26
- t.equal(isFalse(FALSE), TRUE, 'isFalse(FALSE) should return TRUE')
27
- t.equal(isFalse(TRUE), FALSE, 'isFalse(TRUE) should return FALSE')
28
-
29
- combinations.forEach((params) => {
30
- // Check if False() returns the exact FALSE constant (which is boolean false)
31
- t.equal(False(...params), FALSE, `False(${params.join(", ")}) should return FALSE`)
32
- })
33
- })
1
+ // spec/tape.test.js
2
+
3
+ const test = require("tape")
4
+
5
+ // Load the library components from the specified path
6
+ const fjs = require("../dist/index").default
7
+ const False = fjs.False
8
+ const isFalse = fjs.isFalse
9
+
10
+ // Define constants
11
+ const FALSE = 1 == 3
12
+ const TRUE = 1 == 1
13
+
14
+ // Sampled Combinations
15
+ const combinations = [
16
+ ["no", "no", "no", "no", "no", "no", "none"],
17
+ ["yes", "yes", "yes", "no", "no", "no", "netscape"],
18
+ ]
19
+
20
+ // Tape uses the 't' object for assertions (t.equal, t.ok, t.plan)
21
+
22
+ test("FalseJS Core Functions", function (t) {
23
+ // Plan the number of assertions expected in this main block (2 assertions + 2 combination blocks * 2 assertions each)
24
+ t.plan(2 + combinations.length)
25
+
26
+ t.equal(isFalse(FALSE), TRUE, "isFalse(FALSE) should return TRUE")
27
+ t.equal(isFalse(TRUE), FALSE, "isFalse(TRUE) should return FALSE")
28
+
29
+ combinations.forEach((params) => {
30
+ // Check if False() returns the exact FALSE constant (which is boolean false)
31
+ t.equal(
32
+ False(...params),
33
+ FALSE,
34
+ `False(${params.join(", ")}) should return FALSE`,
35
+ )
36
+ })
37
+ })