Socialify

Folder ..

Viewing isConfigured.test.js
35 lines (28 loc) • 738.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import GDrive from 'main/application/sync/gdrive'

describe('#isConfigured', () => {
  let sync, data

  beforeEach(() => {
    const cryptor = { decrypt: () => data }
    sync = new GDrive()
    sync.initialize({}, cryptor)
  })

  afterEach(() => {
    jest.clearAllMocks()
  })

  describe('access_token is present', () => {
    beforeEach(() => {
      data = '{"access_token": "qwert","refresh_token": "asdf"}'
    })

    test('returns true', () => {
      expect(sync.isConfigured()).toEqual(true)
    })
  })

  describe('access_token is not present', () => {
    beforeEach(() => {
      data = '{"refresh_token": "asdf"}'
    })

    test('returns false', () => {
      expect(sync.isConfigured()).toEqual(false)
    })
  })
})