Skip to content

Commit 61eb160

Browse files
committed
refactor(test:endpoint): break out jshint suite into helper function
1 parent 17d9985 commit 61eb160

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/test/endpoint.test.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ function jshint(_path, opt={}) {
113113
return runCmd(cmd);
114114
});
115115
}
116+
117+
function jshintDir(dir, name, folder) {
118+
if(!folder) folder = name;
119+
let endpointDir = path.join(dir, 'server/api', folder);
120+
121+
let regFiles = fs.readdirAsync(endpointDir)
122+
.then(files => files.filter(file => minimatch(file, '**/!(*.spec|*.mock|*.integration).js', {dot: true})))
123+
.map(file => jshint(path.join('./server/api/', folder, file)));
124+
125+
let specFiles = fs.readdirAsync(endpointDir)
126+
.then(files => files.filter(file => minimatch(file, '**/+(*.spec|*.mock|*.integration).js', {dot: true})))
127+
.map(file => jshint(path.join('./server/api/', folder, file), {config: 'server/.jshintrc-spec'}));
128+
129+
return Promise.all([regFiles, specFiles]);
116130
}
117131

118132
var config;
@@ -154,16 +168,7 @@ describe('angular-fullstack:endpoint', function() {
154168
it('should pass jscs');
155169

156170
it('should pass lint', function() {
157-
let endpointDir = path.join(dir, 'server/api/foo/');
158-
let regFiles = fs.readdirAsync(endpointDir)
159-
.then(files => files.filter(file => minimatch(file, '**/!(*.spec|*.mock|*.integration).js', {dot: true})))
160-
.map(file => jshint(`./server/api/foo/${file}`));
161-
162-
let specFiles = fs.readdirAsync(endpointDir)
163-
.then(files => files.filter(file => minimatch(file, '**/+(*.spec|*.mock|*.integration).js', {dot: true})))
164-
.map(file => jshint(`./server/api/food/${file}`, {config: 'server/.jshintrc-spec'}));
165-
166-
return Promise.all([regFiles, specFiles]).should.be.fulfilled();
171+
return jshintDir(dir, 'foo').should.be.fulfilled();
167172
});
168173
});
169174

0 commit comments

Comments
 (0)