Skip to content

Commit 20c6b3f

Browse files
committedFeb 8, 2018
team_info: test files without special blocks
1 parent fd931d4 commit 20c6b3f

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed
 

‎lib/team_info.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ TeamInfo.update = async function(cli, request, content) {
8484
}
8585

8686
if (blocks.size === 0) {
87-
throw new Error(`Could not find block matching ${RE}`);
87+
throw new Error(
88+
'Could not find blocks matching <!-- ncu-team-sync.team($org/$team)>'
89+
);
8890
}
8991

9092
const RE_CLONE = new RegExp(RE.source, 'mg');

‎test/fixtures/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
const fs = require('fs');
44
const path = require('path');
55

6-
exports.readFile = function(filePath) {
7-
const file = path.resolve(__dirname, filePath);
6+
exports.readFile = function(...args) {
7+
const file = path.resolve(__dirname, ...args);
88
return fs.readFileSync(file, 'utf8');
99
};
1010

11-
exports.readJSON = function(filePath) {
12-
const file = exports.readFile(filePath);
11+
exports.readJSON = function(...args) {
12+
const file = exports.readFile(...args);
1313
return JSON.parse(file);
1414
};
1515

@@ -19,6 +19,6 @@ exports.patchPrototype = function(arr, key, proto) {
1919
}
2020
};
2121

22-
exports.path = function(file) {
23-
return path.resolve(__dirname, file);
22+
exports.path = function(...args) {
23+
return path.resolve(__dirname, ...args);
2424
};

‎test/unit/team_info.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,20 @@ describe('TeamInfo', function() {
6262
const actual = readFile('ncu_team_sync_out.md');
6363
assert.strictEqual(expected, actual);
6464
});
65+
66+
it('syncFile() with a file without special blocks', async() => {
67+
const expected = readFile('README', 'README.md');
68+
let thrown = null;
69+
try {
70+
await TeamInfo.syncFile(cli, request, getPath('README', 'README.md'));
71+
} catch (err) {
72+
thrown = err;
73+
}
74+
75+
assert(thrown instanceof Error);
76+
assert(thrown.message, 'Could not find blocks matching ' +
77+
'<!-- ncu-team-sync.team($org/$team)>');
78+
const actual = readFile('README', 'README.md');
79+
assert.strictEqual(expected, actual);
80+
});
6581
});

0 commit comments

Comments
 (0)
Please sign in to comment.