-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
28 lines (22 loc) · 1.13 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const test = require('node:test');
const assert = require('node:assert/strict');
const configFile = require('./index');
const prettier = require('prettier');
test('Prettier Configuration File', () => {
assert.ok(configFile, 'is valid module export');
assert.ok(typeof configFile === 'object', 'is type of object');
});
test('Line length', async () => {
const candidate1 = "console.log('Test');\n";
assert.ok(await prettier.check(candidate1, { ...configFile, filepath: './index.js' }));
const candidate2 = `console.log('${'a'.repeat(104)}');\n`;
assert.ok(await prettier.check(candidate2, { ...configFile, filepath: './index.js' }));
const candidate3 = `console.log('${'a'.repeat(105)}');\n`;
assert.strictEqual(await prettier.check(candidate3, { ...configFile, filepath: './index.js' }), false);
});
test('Single quotes', async () => {
const candidate1 = "console.log('Test');\n";
assert.ok(await prettier.check(candidate1, { ...configFile, filepath: './index.js' }));
const candidate2 = 'console.log("Test");\n';
assert.strictEqual(await prettier.check(candidate2, { ...configFile, filepath: './index.js' }), false);
});