Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions field-logic/src/lib/flattener.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { SurveyFlattener } from './flattener';
import { SurveyFlattener, NA_RESPONSE } from './flattener';
import type { SurveyDefinition, UserSession } from '../types/schema';

const mockSurvey: SurveyDefinition = {
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('SurveyFlattener', () => {
const row = flattener.flattenResponse(session);

// q2 should be SKIPPED
expect(row[2]).toBe('N/A');
expect(row[2]).toBe(NA_RESPONSE);
});

it('toCSV should generate a valid CSV string', () => {
Expand Down
4 changes: 3 additions & 1 deletion field-logic/src/lib/flattener.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { SurveyDefinition, UserSession } from '../types/schema';

export const NA_RESPONSE = 'N/A';

export class SurveyFlattener {
constructor(private definition: SurveyDefinition) { }

Expand All @@ -21,7 +23,7 @@ export class SurveyFlattener {
return answer !== undefined ? answer : null;
} else {
// If NOT visited -> Skipped
return 'N/A';
return NA_RESPONSE;
}
});
}
Expand Down