spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[CriteriaFunctionFactory] adding tests
author
Ben Vogt <[email protected]>
date
2017-05-17 02:35:50
stats
3 file(s) changed, 19 insertions(+), 9 deletions(-)
files
README.md
tests/Utilities/ArgsCheckerTest.ts
tests/Utilities/CriteriaFunctionFactoryTest.ts
 1diff --git a/README.md b/README.md
 2index 7d8cde8..618c91f 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -21,10 +21,6 @@ Things I should do.
 6 http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
 7 
 8 
 9-### functions that throw errors should usually be able to include their caller in the error
10-e.g. "SUM expects number values...", or "This function expects number values..."
11-
12-
13 ### Cells should have `formatAs` fields.
14 Instead of having non-primitives, (i.e. Date, DateTime, Time, Dollar), cells should have formats based on the
15 highest-order type that was used during the compilation and execution of a cell's dependency. For example, `DATE` might
16@@ -65,9 +61,6 @@ TypeConverter.
17 ### Ensure all formulas are tested inside of SheetFormulaTest.ts
18 
19 
20-### Test CriteriaFunctionFactory
21-
22-
23 ### Pull static functions outside of formulas, declare once.
24 
25 
26diff --git a/tests/Utilities/ArgsCheckerTest.ts b/tests/Utilities/ArgsCheckerTest.ts
27index 8a1be62..1e82b8b 100644
28--- a/tests/Utilities/ArgsCheckerTest.ts
29+++ b/tests/Utilities/ArgsCheckerTest.ts
30@@ -1,6 +1,5 @@
31 import {
32   assertEquals,
33-  catchAndAssertEquals,
34   test
35 } from "../Utils/Asserts";
36 import {
37diff --git a/tests/Utilities/CriteriaFunctionFactoryTest.ts b/tests/Utilities/CriteriaFunctionFactoryTest.ts
38new file mode 100644
39index 0000000..f079a31
40--- /dev/null
41+++ b/tests/Utilities/CriteriaFunctionFactoryTest.ts
42@@ -0,0 +1,19 @@
43+import {
44+  assertEquals,
45+  test
46+} from "../Utils/Asserts";
47+import {
48+  CriteriaFunctionFactory
49+} from "../../src/Utilities/CriteriaFunctionFactory";
50+
51+
52+test("CriteriaFunctionFactory.createCriteriaFunction", function () {
53+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction("=10")(10), true);
54+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction("=10")(0), false);
55+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction(">2")(3), true);
56+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction(">2")(2), false);
57+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction(">2")(1), false);
58+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction("<>2")(1), true);
59+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction("<>2")(2), false);
60+  assertEquals(CriteriaFunctionFactory.createCriteriaFunction("?o?")("top"), true);
61+});