Skip to content

Commit 0fb2e83

Browse files
bhovhannescitizensas
authored andcommitted
chore: add tests
1 parent d5428f1 commit 0fb2e83

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

test/integration/batch.spec.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright 2015 Workfront
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import * as fetchMock from 'fetch-mock'
18+
import should from 'should'
19+
20+
import * as Workfront from '../../src/index'
21+
22+
const API_URL = 'http://foobar:8080'
23+
24+
describe('Batch', function() {
25+
26+
afterEach(fetchMock.reset)
27+
afterEach(fetchMock.restore)
28+
29+
beforeEach(function() {
30+
this.api = new Workfront.Api({
31+
url: API_URL
32+
})
33+
})
34+
afterEach(function() {
35+
this.api = undefined
36+
})
37+
38+
beforeEach(function() {
39+
fetchMock.mock(
40+
`begin:${API_URL}/attask/api`,
41+
200,
42+
{
43+
name: 'any'
44+
}
45+
)
46+
})
47+
48+
it('should not make any network calls in uriCollector callback', function() {
49+
this.api.batch(
50+
batchApi => [
51+
batchApi.copy('foo', 'bar', {name: 'Copy of bar'}),
52+
batchApi.count('USER', {}),
53+
batchApi.create('baz', {
54+
foo: 'bar'
55+
}, ['*', 'zzz:*']),
56+
batchApi.edit('PROJ', 'foobar', {
57+
name: 'api test 2'
58+
}),
59+
batchApi.execute('foo', 'bar', 'baz'),
60+
batchApi.get('foo', 'bar'),
61+
batchApi.metadata('TASK', ['collections']),
62+
batchApi.namedQuery('foo', 'action'),
63+
batchApi.remove('foo', 'objID'),
64+
batchApi.report('task', {
65+
'status_GroupBy': true
66+
}),
67+
batchApi.search('role', {
68+
'status_GroupBy': true
69+
})
70+
],
71+
false
72+
)
73+
should(fetchMock.calls().matched.length).equal(1)
74+
})
75+
})

0 commit comments

Comments
 (0)