'use strict';

var fs      = require('fs');
var hljs    = require('../build');
var utility = require('./utility');

function testAutoDetection(language) {
  it('should be detected as ' + language, function() {
    var filename     = language + '.txt',
        languagePath = utility.buildPath('language', filename),
        content      = fs.readFileSync(languagePath, 'utf-8'),

        expected = language,
        actual   = hljs.highlightAuto(content).language;

    actual.should.equal(expected);
  });
}

describe('hljs', function() {
  describe('.highlightAuto', function() {
    var languages = utility.languagesList();

    languages.forEach(testAutoDetection);
  });
});

'use strict';

var fs      = require('fs');
var hljs    = require('../build');
var path    = require('path');
var utility = require('./utility');

function testAutoDetection(language) {
  it('should be detected as ' + language, function() {
    var languagePath = utility.buildPath('language', language),
        examples     = fs.readdirSync(languagePath);

    examples.forEach(function(example) {
      var filename = path.join(languagePath, example),
          content  = fs.readFileSync(filename, 'utf-8'),

          expected = language,
          actual   = hljs.highlightAuto(content).language;

      actual.should.equal(expected);
    });
  });
}

describe('hljs', function() {
  describe('.highlightAuto', function() {
    var languages = utility.languagesList();

    languages.forEach(testAutoDetection);
  });
});

Change testAutoDetection to handle multiple files
Change testAutoDetection to handle multiple files
