Skip to content

Commit 8997f0e

Browse files
committed
Added missing test fixture files (and some comments)
1 parent 4767395 commit 8997f0e

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

fixtures/test-validation.csv

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
TEST SPREADSHEET,,,,,,
2+
required string,required number,optional string,optional number,,,
3+
Name,Age,Egginess,Weight,,Valid?,Comment
4+
Boris,13,High,5.5,,TRUE,All fields present
5+
,,,,,FALSE,All fields blank; row will be silently ignored
6+
Nelly,10,,,,TRUE,Optional fields absent
7+
Sid,twelve,,,,FALSE,Invalid required number
8+
,nine,,,,FALSE,"Missing required string, invalid required number"
9+
Dave,15,,unknown,,TRUE,Invalid optional number

fixtures/test-validation.ods

12.6 KB
Binary file not shown.

fixtures/test-validation.xlsx

6.33 KB
Binary file not shown.

lib/importer/attribute-types.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,6 @@
22
// simple string/boolean/number/date/etc things. "attribute values" are the
33
// actual attributes in our output data model and can be some arbitrary type.
44

5-
// Am attribute type is a pair of functions.
6-
7-
// One validates an input value to see if it can be made into a valid attribute
8-
// value. It should return a list of warnings and a list of errors.
9-
10-
// One maps an input value to a value of the attribute type.
11-
12-
// ABS TODOs: Make validation and translation happen together - drop
13-
// AttributeType and just implement it as a function from input value ->
14-
// (outputValue, [warning], [error]).
15-
16-
// This will enable optionalType to handle errors from the base type by turning
17-
// them into warnings *and* returning undefined as the translater value.
18-
19-
// Then add a requiredType that wraps any type and makes it "required", treating
20-
// "" or undefined inputs as errors.
21-
22-
// Base types without being wrapped by requiredType or optionalType may then
23-
// handled undefined or "" as they see fit.
24-
255
// An attribute type is a function from an input value to a result.
266

277
class AttributeMappingResult {

lib/importer/backend.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ test('validation', () => {
505505
warningCount: 1
506506
});
507507

508-
const warnings = backend.JobGetWarnings(jid);
508+
const warnings = backend.JobGetWarnings(jid); // Weight is optional so errors here become warnings
509509
expect(warnings).toMatchObject(new Map([[8, [['Weight', 'This is not a valid number']]]]));
510510

511511
const errors = backend.JobGetErrors(jid);

0 commit comments

Comments
 (0)