@@ -8,13 +8,14 @@ chai.use(require('chai-datetime'));
8
8
chai . should ( ) ;
9
9
const sinon = require ( 'sinon' ) ;
10
10
import { API_V1 } from '../../../lib/util/Constants' ;
11
- import { taskQueueList , taskQueuesPage0 , taskQueuesPage1 , workerList , workerListPage0 , workerListPage1 , workerList2Page0 , workerList2Page1 } from '../../mock/Workspace' ;
11
+ import { taskQueueList , taskQueuesPage0 , taskQueuesPage1 , workerList , workerListPage0 , workerListPage1 , workerList2Page0 , workerList2Page1 , taskList } from '../../mock/Workspace' ;
12
12
import { adminToken , token , updatedAdminToken } from '../../mock/Token' ;
13
13
import Request from '../../../lib/util/Request' ;
14
14
import path from 'path' ;
15
15
import TaskQueue from '../../../lib/TaskQueue' ;
16
16
import WorkerContainer from '../../../lib/WorkerContainer' ;
17
17
import Configuration from '../../../lib/util/Configuration' ;
18
+ import TaskDescriptor from '../../../lib/descriptors/TaskDescriptor' ;
18
19
19
20
describe ( 'Workspace' , ( ) => {
20
21
@@ -253,6 +254,31 @@ describe('Workspace', () => {
253
254
254
255
} ) ;
255
256
257
+ describe ( '#fetchTasks' , ( ) => {
258
+ const requestURL = 'Workspaces/WSxxx/Tasks' ;
259
+
260
+ let sandbox ;
261
+ beforeEach ( ( ) => {
262
+ sandbox = sinon . sandbox . create ( ) ;
263
+ } ) ;
264
+
265
+ afterEach ( ( ) => sandbox . restore ( ) ) ;
266
+
267
+ it ( 'should fetch task with sid' , ( ) => {
268
+ const workspace = new Workspace ( adminToken ) ;
269
+ const taskInstance = taskList . contents [ 0 ] ;
270
+ const url = path . join ( requestURL , taskInstance . sid ) ;
271
+ const stub = sandbox . stub ( Request . prototype , 'get' ) . withArgs ( url , API_V1 ) . returns ( Promise . resolve ( taskInstance ) ) ;
272
+
273
+ return workspace . fetchTask ( taskInstance . sid ) . then ( queue => {
274
+ expect ( queue . sid ) . to . equal ( taskInstance . sid ) ;
275
+ expect ( queue ) . to . be . instanceOf ( TaskDescriptor ) ;
276
+ expect ( stub . withArgs ( url , API_V1 ) . calledOnce ) . to . be . true ;
277
+ } ) ;
278
+ } ) ;
279
+
280
+ } ) ;
281
+
256
282
257
283
describe ( '#updateToken' , ( ) => {
258
284
0 commit comments