/*
 * searchsettings_test.js
 *
 * Some nodeunit tests of searchsettings.js
 */

const SearchSettings = require('../src/searchsettings.js').SearchSettings;

exports.testDefaultSettings = function(test) {
    var settings = new SearchSettings();
    test.ok(!settings.archivesOnly, "archivesOnly is false by default");
    test.ok(!settings.debug, "debug is false by default");
    test.ok(settings.excludeHidden, "excludeHidden is true by default");
    test.ok(!settings.firstMatch, "firstmatch is false by default");
    test.ok(settings.linesAfter === 0, "linesAfter == 0 by default");
    test.ok(settings.linesBefore === 0, "linesBefore == 0 by default");
    test.ok(!settings.listDirs, "listDirs is false by default");
    test.ok(!settings.listFiles, "listFiles is false by default");
    test.ok(!settings.listLines, "listLines is false by default");
    test.ok(settings.maxLineLength == 150, "maxLineLength == 150 by default");
    test.ok(!settings.multilineSearch, "multilineSearch is false by default");
    test.ok(!settings.printResults, "printResults is true by default");
    test.ok(!settings.printUsage, "printUsage is false by default");
    test.ok(!settings.printVersion, "printVersion is false by default");
    test.ok(settings.recursive, "recursive is true by default");
    test.ok(!settings.searchArchives, "searchArchives is false by default");
    test.ok(settings.startPath === '', "startPath is empty by default");
    test.ok(!settings.uniqueLines, "uniqueLines is false by default");
    test.ok(!settings.verbose, "verbose is false by default");
    test.done();
};

exports.testAddExtensions = function(test) {
    var settings = new SearchSettings();
    settings.addInExtension("js,java");
    test.ok(settings.inExtensions.length === 2, "inExtensions has two extensions");
    test.ok(settings.inExtensions[0] === 'js', "first extension is js");
    test.ok(settings.inExtensions[1] === 'java', "first extension is java");
    test.done();
};

exports.testAddSearchPattern = function(test) {
    var settings = new SearchSettings();
    settings.addSearchPattern("Searcher");
    test.ok(settings.searchPatterns.length === 1, "searchPatterns has one pattern");
    test.ok(settings.searchPatterns[0].source === 'Searcher', "pattern is /Searcher/");
    test.done();
};

exports.testSetArchivesOnly = function(test) {
    var settings = new SearchSettings();
    test.ok(settings.archivesOnly === false, "archivesOnly is false by default");
    test.ok(settings.searchArchives === false, "searchArchives is false by default");
    settings.setArchivesOnly();
    test.ok(settings.archivesOnly === true, "archivesOnly is now true");
    test.ok(settings.searchArchives === true, "searchArchives is now true");
    test.done();
};

exports.testSetDebug = function(test) {
    var settings = new SearchSettings();
    test.ok(settings.debug === false, "debug is false by default");
    test.ok(settings.verbose === false, "verbose is false by default");
    settings.setDebug();
    test.ok(settings.debug === true, "debug is now true");
    test.ok(settings.verbose === true, "verbose is now true");
    test.done();
};

@@ -193,35 +193,37 @@
 ion(test) %7B%0A    
-var
+const
  settings = new 
@@ -888,24 +888,25 @@
 ineLength ==
+=
  150, %22maxLi
@@ -1623,16 +1623,38 @@
 tensions
+AsCommaSeparatedString
  = funct
@@ -1661,35 +1661,35 @@
 ion(test) %7B%0A    
-var
+let
  settings = new 
@@ -1993,32 +1993,424 @@
 est.done();%0A%7D;%0A%0A
+exports.testAddExtensionsAsArray = function(test) %7B%0A    let settings = new SearchSettings();%0A    settings.addInExtension(%5B%22js%22,%22java%22%5D);%0A    test.ok(settings.inExtensions.length === 2, %22inExtensions has two extensions%22);%0A    test.ok(settings.inExtensions%5B0%5D === 'js', %22first extension is js%22);%0A    test.ok(settings.inExtensions%5B1%5D === 'java', %22first extension is java%22);%0A    test.done();%0A%7D;%0A%0A
 exports.testAddS
@@ -2437,35 +2437,35 @@
 ion(test) %7B%0A    
-var
+let
  settings = new 
@@ -2711,32 +2711,465 @@
 est.done();%0A%7D;%0A%0A
+exports.testAddSearchPatterns = function(test) %7B%0A    let settings = new SearchSettings();%0A    settings.addSearchPattern(%5B%22Searcher%22, %22FileTypes%22%5D);%0A    test.ok(settings.searchPatterns.length === 2, %22searchPatterns has two patterns%22);%0A    test.ok(settings.searchPatterns%5B0%5D.source === 'Searcher', %22pattern is /Searcher/%22);%0A    test.ok(settings.searchPatterns%5B1%5D.source === 'FileTypes', %22pattern is /FileTypes/%22);%0A    test.done();%0A%7D;%0A%0A
 exports.testSetA
@@ -3195,35 +3195,35 @@
 ion(test) %7B%0A    
-var
+let
  settings = new 
@@ -3659,11 +3659,11 @@
     
-var
+let
  set

Add tests for adding extensions and patterns as array, other minor enhancements