Ticket/InsdepUI/plugin/highlight-9.9.0/test/detect/index.js
(完整代码) 1KB'use strict';
let bluebird = require('bluebird');
let fs = bluebird.promisifyAll(require('fs'));
let hljs = require('../../build');
let path = require('path');
let utility = require('../utility');
function testAutoDetection(language) {
const languagePath = utility.buildPath('detect', language);
it(`should have test for ${language}`, function() {
return fs.statAsync(languagePath)
.then(path => path.isDirectory().should.be.true);
});
it(`should be detected as ${language}`, function() {
return fs.readdirAsync(languagePath)
.map(function(example) {
const filename = path.join(languagePath, example);
return fs.readFileAsync(filename, 'utf-8');
})
.each(function(content) {
const expected = language,
actual = hljs.highlightAuto(content).language;
actual.should.equal(expected);
});
});
}
describe('hljs.highlightAuto()', function() {
const languages = hljs.listLanguages();
languages.forEach(testAutoDetection);
});
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。