UNPKG

12.9 kBJavaScriptView Raw
1/**
2 * Test case for apemanSrch.
3 * Runs with mocha.
4 */
5"use strict";
6
7const https = require('https'),
8 injectmock = require('injectmock'),
9 assert = require('assert');
10
11let apemanSrch = require('../lib/apeman_srch.js');
12
13describe('apeman-srch', () => {
14
15 it('Run command.', (done) => {
16 injectmock(https, 'get', function (config, callback) {
17 let data = [
18 {
19 name: 'apeman-task-mkdir',
20 full_name: 'apeman-task-labo/apeman-task-mkdir',
21 private: false,
22 description: 'apeman task to generate directories.',
23 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-mkdir',
24 fork: false
25 },
26 {
27 name: 'apeman-task-chmod',
28 full_name: 'apeman-task-labo/apeman-task-chmod',
29 private: false,
30 description: 'apeman task to change file permissions',
31 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-chmod',
32 fork: false
33 },
34 {
35 name: 'apeman-task-coz',
36 full_name: 'apeman-task-labo/apeman-task-coz',
37 private: false,
38 description: 'apeman task to render coz bud files.',
39 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-coz',
40 fork: false
41 },
42 {
43 name: 'apeman-task-copy',
44 full_name: 'apeman-task-labo/apeman-task-copy',
45 private: false,
46 description: 'apeman task to copy files.',
47 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-copy',
48 fork: false
49 },
50 {
51 name: 'apeman-task-concat',
52 full_name: 'apeman-task-labo/apeman-task-concat',
53 private: false,
54 description: 'apeman task to concat files.',
55 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-concat',
56 fork: false
57 },
58 {
59 name: 'apeman-task-mocha',
60 full_name: 'apeman-task-labo/apeman-task-mocha',
61 private: false,
62 description: 'apeman task to run mocha.',
63 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-mocha',
64 fork: false
65 },
66 {
67 name: 'apeman-task-mocha',
68 full_name: 'apeman-task-labo/apeman-task-mocha',
69 private: false,
70 description: 'apeman task to run mocha.',
71 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-mocha',
72 fork: false
73 },
74 {
75 name: 'apeman-task-karma',
76 full_name: 'apeman-task-labo/apeman-task-karma',
77 private: false,
78 description: 'apeman task to run karma.',
79 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-karma',
80 fork: false
81 },
82 {
83 name: 'apeman-task-jade',
84 full_name: 'apeman-task-labo/apeman-task-jade',
85 private: false,
86 description: 'apeman task to compile jade files.',
87 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-jade',
88 fork: false
89 },
90 {
91 name: 'apeman-task-symlink',
92 full_name: 'apeman-task-labo/apeman-task-symlink',
93 private: false,
94 description: 'apeman task to create symlink.',
95 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-symlink',
96 fork: false
97 },
98 {
99 name: 'apeman-task-task',
100 full_name: 'apeman-task-labo/apeman-task-task',
101 private: false,
102 description: 'apeman task to run other apeman tasks.',
103 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-task',
104 fork: false
105 },
106 {
107 name: 'apeman-task-execcli',
108 full_name: 'apeman-task-labo/apeman-task-execcli',
109 private: false,
110 description: 'apeman task to execute cli command.',
111 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-execcli',
112 fork: false
113 },
114 {
115 name: 'apeman-task-scss',
116 full_name: 'apeman-task-labo/apeman-task-scss',
117 private: false,
118 description: 'apeman task to compile sass.',
119 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-scss',
120 fork: false
121 },
122 {
123 name: 'apeman-task-versionup',
124 full_name: 'apeman-task-labo/apeman-task-versionup',
125 private: false,
126 description: 'apeman task to increment package version.',
127 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-versionup',
128 fork: false
129 },
130 {
131 name: 'apeman-task-taggit',
132 full_name: 'apeman-task-labo/apeman-task-taggit',
133 private: false,
134 description: 'apeman task to create git tag.',
135 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-taggit',
136 fork: false
137 },
138 {
139 name: 'apeman-task-jsdoc',
140 full_name: 'apeman-task-labo/apeman-task-jsdoc',
141 private: false,
142 description: 'apeman task to generate jsdoc.',
143 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-jsdoc',
144 fork: false
145 },
146 {
147 name: 'apeman-task-coverage',
148 full_name: 'apeman-task-labo/apeman-task-coverage',
149 private: false,
150 description: 'apeman task to measure coverage.',
151 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-coverage',
152 fork: false
153 },
154 {
155 name: 'apeman-task-fmtjson',
156 full_name: 'apeman-task-labo/apeman-task-fmtjson',
157 private: false,
158 description: 'apeman task to format json files.',
159 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-fmtjson',
160 fork: false
161 },
162 {
163 name: 'apeman-task-apiguide',
164 full_name: 'apeman-task-labo/apeman-task-apiguide',
165 private: false,
166 description: 'apeman task to generate apiguide',
167 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-apiguide',
168 fork: false
169 },
170 {
171 name: 'apeman-task-bower',
172 full_name: 'apeman-task-labo/apeman-task-bower',
173 private: false,
174 description: 'apeman task to install bower components.',
175 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-bower',
176 fork: false
177 },
178 {
179 name: 'apeman-task-update',
180 full_name: 'apeman-task-labo/apeman-task-update',
181 private: false,
182 description: 'apeman task to update package dependencies.',
183 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-update',
184 fork: false
185 },
186 {
187 name: 'apeman-task-sure',
188 full_name: 'apeman-task-labo/apeman-task-sure',
189 private: false,
190 description: 'apeman task to ask sure',
191 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-sure',
192 fork: false
193 },
194 {
195 name: 'apeman-task-push',
196 full_name: 'apeman-task-labo/apeman-task-push',
197 private: false,
198 description: 'apeman task to push git.',
199 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-push',
200 fork: false
201 },
202 {
203 name: 'apeman-task-publish',
204 full_name: 'apeman-task-labo/apeman-task-publish',
205 private: false,
206 description: 'apeman task to publish npm package.',
207 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-publish',
208 fork: false
209 },
210 {
211 name: 'apeman-task-install',
212 full_name: 'apeman-task-labo/apeman-task-install',
213 private: false,
214 description: 'apeman task to install npm packages.',
215 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-install',
216 fork: false
217 },
218 {
219 name: 'apeman-task-tmpl',
220 full_name: 'apeman-task-labo/apeman-task-tmpl',
221 private: false,
222 description: 'apeman task to run apeman tmpl command.',
223 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-tmpl',
224 fork: false
225 },
226 {
227 name: 'apeman-task-codeclimate',
228 full_name: 'apeman-task-labo/apeman-task-codeclimate',
229 private: false,
230 description: 'apeman task to send test report to codeclimate.com',
231 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-codeclimate',
232 fork: false
233 },
234 {
235 name: 'apeman-task-clean',
236 full_name: 'apeman-task-labo/apeman-task-clean',
237 private: false,
238 description: 'apeman task to delete files.',
239 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-clean',
240 fork: false
241 },
242 {
243 name: 'apeman-task-jsx',
244 full_name: 'apeman-task-labo/apeman-task-jsx',
245 private: false,
246 description: 'apeman task to compile jsx files.',
247 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-jsx',
248 fork: false
249 },
250 {
251 name: 'apeman-task-browserify',
252 full_name: 'apeman-task-labo/apeman-task-browserify',
253 private: false,
254 description: 'apeman task to run browserify.',
255 url: 'https://api.github.com/repos/apeman-task-labo/apeman-task-browserify',
256 fork: false
257 }
258 ];
259 while(data.length < 20){
260 data.push({});
261 }
262 let content = JSON.stringify(data);
263 let res = {
264 on(ev, callback) {
265 switch (ev) {
266 case 'data':
267 setTimeout(() => {
268 callback(content);
269 }, 5);
270 break;
271 case 'end':
272 setTimeout(() => {
273 callback(null);
274 }, 20);
275 break;
276 }
277 },
278 statusCode: 200
279 };
280 callback(res);
281 });
282 apemanSrch("pu", {type: 'task'}).then(
283 () => done(),
284 err => {
285 assert.ifError(err);
286 done();
287 }
288 );
289 });
290});
291