1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-08-28 12:02:40 +00:00
TiddlyWiki5/editions/test/tiddlers/tests/modules/utils/test-csv.js
2022-11-20 17:51:01 +00:00

34 lines
938 B
JavaScript

/*\
title: modules/utils/test-csv.js
type: application/javascript
tags: [[$:/tags/test-spec]]
Tests the backlinks mechanism.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
describe('CSV Parsing', function() {
var tid = $tw.wiki.getTiddler('csv-cases');
var testCases = JSON.parse(tid.fields.text);
$tw.utils.each(testCases, function(testCase) {
if (testCase.skip) {
return;
}
it("Test case: " + testCase.name, function() {
var parsedCsv = $tw.utils.parseCsvString(testCase.csv, testCase.options);
expect(parsedCsv).withContext("The generated CSV should match the expected one").toEqual(testCase.json);
var parsedCsvWithHeaders = $tw.utils.parseCsvStringWithHeader(testCase.csv, testCase.options);
expect(parsedCsvWithHeaders).withContext("The generated CSV with headers should match the expected one").toEqual(testCase.jsonWithHeaders);
});
})
});
})();