Skip to content
Snippets Groups Projects
Commit eb69b491 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

feat: add TU

parent d3433a75
No related branches found
No related tags found
2 merge requests!19Feat/us858 save expiration date,!17fix/US846-onDelete
Pipeline #42482 passed
const { isAlpha } = require('../../src/helpers/env')
describe('isAlpha', () => {
const OLD_ENV = process.env
beforeEach(() => {
jest.resetModules() // Most important - it clears the cache
process.env = { ...OLD_ENV } // Make a copy
})
afterAll(() => {
process.env = OLD_ENV // Restore old environment
})
it('should return false for local', () => {
// Set the variables
process.env.COZY_URL = 'http://cozy.tools:8080'
const reply = isAlpha()
expect(reply).toBe(false)
})
it('should return false for prod URL', () => {
// Set the variables
process.env.COZY_URL = 'https://pouet-ecolyo.cozygrandlyon.cloud/'
const reply = isAlpha()
expect(reply).toBe(false)
})
it('should return true for alpha', () => {
// Set the variables
process.env.COZY_URL = 'https://pouet.cozy.self-data.alpha.grandlyon.com/'
const reply = isAlpha()
expect(reply).toBe(true)
})
})
const { cozyClient } = require('cozy-konnector-libs')
const { getAccount, saveAccountData } = require('../../src/requests/cozy')
const {
getAccount,
saveAccountData,
getAccountForDelete,
} = require('../../src/requests/cozy')
const mockUpdateOrCreate = jest.fn()
......@@ -36,6 +40,39 @@ describe('getAccount', () => {
})
})
})
describe('getAccountForDelete', () => {
it('should find account with provided ID', async () => {
const spy = jest.spyOn(cozyClient, 'fetchJSON')
spy.mockResolvedValueOnce(
{
_id: '123456',
account_type: '123456',
auth: {
address: '12 rue du pouet',
city: 'Lyon',
firstname: 'Jean',
lastname: 'POUET',
pointId: '1234567891234567',
postalCode: '69007',
},
},
{ _id: '1111111', account_type: '1111111' }
)
const account = await getAccountForDelete('123456', '789456')
expect(account).toEqual({
_id: '123456',
account_type: '123456',
auth: {
address: '12 rue du pouet',
city: 'Lyon',
firstname: 'Jean',
lastname: 'POUET',
pointId: '1234567891234567',
postalCode: '69007',
},
})
})
})
describe('saveAccountData', () => {
jest.mock('cozy-konnector-libs', () => ({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment