mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Add tests for clusterctl's output formatting
Add tests for formatOutput and formatOutputColored by using the same lines as the line parser uses for testing.
This commit is contained in:
1 parent
3bccbac496
commit
bfff297d9a
4 files changed
+154
-89
No files matched your search
@@ -0,0 +1,31 @@
|
||||
const assert = require('assert').strict;
|
||||
const chalk = require('chalk');
|
||||
|
||||
const { testLines } = require('./lib/factorio/lines');
|
||||
const clusterctl = require('../clusterctl.js');
|
||||
|
||||
|
||||
describe("clusterctl", function() {
|
||||
describe("formatOutputColored()", function() {
|
||||
it("should pass the test lines", function() {
|
||||
// Ensure tests get uncoloured output.
|
||||
let old = chalk.level;
|
||||
chalk.level = 0;
|
||||
|
||||
for (let [reference, output] of testLines) {
|
||||
let line = clusterctl._formatOutputColored(output);
|
||||
assert.deepEqual(line, reference);
|
||||
}
|
||||
|
||||
chalk.level = old;
|
||||
});
|
||||
});
|
||||
describe("formatOutput()", function() {
|
||||
it("should pass the test lines", function() {
|
||||
for (let [reference, output] of testLines) {
|
||||
let line = clusterctl._formatOutput(output);
|
||||
assert.deepEqual(line, reference);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user