UNPKG

1.46 kBtext/coffeescriptView Raw
1CrmProduct = require('../../../lib/products/crm')
2BaseProduct = require('../../../lib/base-product')
3
4describe 'crm', ->
5 Crm = undefined
6 zoho = { authToken: 'fake-token', region: 'com' }
7
8 beforeEach ->
9 Crm = new CrmProduct(zoho)
10
11 it 'extends BaseProduct', ->
12 expect(CrmProduct.__super__.constructor).toEqual(BaseProduct)
13
14 it 'has name crm', ->
15 expect(Crm.name).toBe('crm')
16
17 describe 'getModules', ->
18
19 it 'returns array', ->
20 expect(Crm.getModules()).toBeDefined()
21
22 it 'contains implemented modules', ->
23 expect(Crm.getModules()).toEqual(['Leads', 'Events', 'Potentials', 'Contacts', 'Accounts', 'CustomModule1'])
24
25 describe 'getModule', ->
26
27 it 'throws exception if module not found', ->
28 expect(() -> Crm.getModule('Invalid') ).toThrow()
29
30 it 'returns instance of valid module', ->
31 leads = Crm.getModule('Leads')
32
33 expect(leads).toBeDefined()
34
35 describe 'getScope', ->
36
37 it 'returns crmapi', ->
38 expect(Crm.getScope()).toBe('crmapi')
39
40 describe 'getBaseUrl', ->
41
42 it 'returns hosnamet: crm.zoho.com', ->
43 expect(Crm.getBaseUrl().hostname).toBe('crm.zoho.com')
44
45 it 'protocol https', ->
46 expect(Crm.getBaseUrl().protocol).toBe('https')
47
48 it 'has default query', ->
49 expect(Crm.getBaseUrl().query).toEqual({
50 authtoken: zoho.authToken
51 scope: 'crmapi'
52 })
53
54 it 'has path with name', ->
55 expect(Crm.getBaseUrl().path).toEqual(['crm'])