Skip to content

Commit

Permalink
refactor: Use a real client for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed May 9, 2019
1 parent 0b28704 commit 3e92266
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 46 deletions.
8 changes: 4 additions & 4 deletions test/lib/stack-client/stack-client.appiconprops.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global __TARGET__ */

import CozyClient from 'cozy-client'
import stack from 'lib/stack-client'

import internal from 'lib/stack-internal'

let oldTarget
Expand All @@ -15,9 +15,9 @@ describe("stack client", () => {
uri: "https://test.mycozy.cloud",
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
17 changes: 9 additions & 8 deletions test/lib/stack-client/stack-client.cozyfetchjson.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import stack from 'lib/stack-client'
import CozyClient from 'cozy-client'

describe("stack client", () => {

Expand All @@ -14,15 +15,15 @@ describe("stack client", () => {
},
json
})
let cozyClient = {
getStackClient: () => {
return {
token: { token: "mytoken"},
uri: "https://test.mycozy.cloud",
fetch
}

let cozyClient = new CozyClient({
stackClient: {
token: { token: "mytoken"},
uri: "https://test.mycozy.cloud",
fetch
}
}
})

let params = {
cozyClient,
onCreateApp: function() {},
Expand Down
8 changes: 4 additions & 4 deletions test/lib/stack-client/stack-client.cozyurl.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stack from 'lib/stack-client'

import CozyClient from 'cozy-client'
import internal from 'lib/stack-internal'

describe("stack client", () => {
Expand All @@ -11,9 +11,9 @@ describe("stack client", () => {
uri: "https://test.mycozy.cloud",
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
7 changes: 4 additions & 3 deletions test/lib/stack-client/stack-client.getapp.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CozyClient from 'cozy-client'
import stack from 'lib/stack-client'

import internal from 'lib/stack-internal'
Expand Down Expand Up @@ -39,9 +40,9 @@ describe("stack client", () => {
})
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
8 changes: 4 additions & 4 deletions test/lib/stack-client/stack-client.getapps.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CozyClient from 'cozy-client'
import stack from 'lib/stack-client'

import internal from 'lib/stack-internal'

describe("stack client", () => {
Expand Down Expand Up @@ -39,9 +39,9 @@ describe("stack client", () => {
)
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
8 changes: 4 additions & 4 deletions test/lib/stack-client/stack-client.getcontext.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stack from 'lib/stack-client'

import CozyClient from 'cozy-client'
import internal from 'lib/stack-internal'

import {
Expand Down Expand Up @@ -46,9 +46,9 @@ describe("stack client", () => {
fetch: jest.fn()
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
8 changes: 4 additions & 4 deletions test/lib/stack-client/stack-client.getstoragedata.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stack from 'lib/stack-client'

import CozyClient from 'cozy-client'
import internal from 'lib/stack-internal'

describe("stack client", () => {
Expand Down Expand Up @@ -47,9 +47,9 @@ describe("stack client", () => {
fetch: jest.fn()
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
14 changes: 6 additions & 8 deletions test/lib/stack-client/stack-client.init.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stack from 'lib/stack-client'

import CozyClient from 'cozy-client'
import internal from 'lib/stack-internal'
import initializeRealtime from 'lib/realtime'

Expand All @@ -10,14 +10,12 @@ const { init } = stack

describe('stack client', () => {
describe('init', () => {
let cozyClient = {
getStackClient: () => {
return {
token: { token: 'mytoken' },
uri: 'https://test.mycozy.cloud'
}
let cozyClient = new CozyClient({
stackClient: {
token: { token: 'mytoken' },
uri: 'https://test.mycozy.cloud'
}
}
})
let params = {
cozyClient,
onCreate: function() {},
Expand Down
7 changes: 4 additions & 3 deletions test/lib/stack-client/stack-client.intents.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Intents } from 'cozy-interapp'
import stack from 'lib/stack-client'
import CozyClient from 'cozy-client'

describe('stack client', () => {
describe('intents', () => {
Expand All @@ -8,9 +9,9 @@ describe('stack client', () => {
uri: 'https://test.mycozy.cloud'
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down
8 changes: 4 additions & 4 deletions test/lib/stack-client/stack-client.logout.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stack from 'lib/stack-client'

import CozyClient from 'cozy-client'
import internal from 'lib/stack-internal'

describe("stack client", () => {
Expand All @@ -12,9 +12,9 @@ describe("stack client", () => {
fetch: jest.fn().mockResolvedValue({status: 200})
}

const cozyClient = {
getStackClient: () => stackClient
}
const cozyClient = new CozyClient({
stackClient
})

const params = {
cozyClient,
Expand Down

0 comments on commit 3e92266

Please sign in to comment.