diff --git a/__tests__/api/general.spec.js b/lib/__tests__/general.spec.js similarity index 82% rename from __tests__/api/general.spec.js rename to lib/__tests__/general.spec.js index 7cb7aeb..49cadfd 100644 --- a/__tests__/api/general.spec.js +++ b/lib/__tests__/general.spec.js @@ -1,6 +1,6 @@ // eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies -const {mockDataObject} = require('mock-data'); // Note mock-data live under __mocks__ dir -const Translate = require('../../lib/translate-json-object'); +const Translate = require('../translate-json-object'); +const mock = require('../fixture/data.fixture'); const TJO = new Translate(); const init = jest.fn(TJO.init); @@ -33,7 +33,7 @@ describe('Translate Module TJO: ', () => { it('should fail to translate() using unkown service', () => { init({unkownApiService: 'apiToken'}); - return translate(mockDataObject, 'ar') + return translate(mock.dataObject, 'ar') .catch(err => { expect(err).toBeDefined(); }); @@ -41,7 +41,7 @@ describe('Translate Module TJO: ', () => { it('Should fail to translate because of a missing language param: fail', () => { init({yandexApiKey: 'apiToken'}); - return translate(mockDataObject) + return translate(mock.dataObject) .catch(err => { expect(err).toBeDefined(); }); @@ -49,7 +49,7 @@ describe('Translate Module TJO: ', () => { it('should TJO.translate fails, becuase of missing google/yandex token', () => { init(); - return translate(mockDataObject, 'ar') + return translate(mock.dataObject, 'ar') .catch(err => { expect(err).toBeDefined(); }); diff --git a/__tests__/api/google.spec.js b/lib/__tests__/google.spec.js similarity index 75% rename from __tests__/api/google.spec.js rename to lib/__tests__/google.spec.js index 7f43ebe..14be68c 100644 --- a/__tests__/api/google.spec.js +++ b/lib/__tests__/google.spec.js @@ -1,6 +1,6 @@ // eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies -const {mockDataObject, transaltedES} = require('mock-data'); // Note mock-data live under __mocks__ dir -const Translate = require('../../lib/translate-json-object'); +const Translate = require('../translate-json-object'); +const mock = require('../fixture/data.fixture'); const TJO = new Translate(); const init = jest.fn(TJO.init); @@ -9,9 +9,9 @@ const translate = jest.fn(TJO.translate); describe('TJO Google Translate Service', () => { it('Should transalte object: sucess', () => { init({googleApiKey: 'apiToken'}); - return translate(mockDataObject, 'es') + return translate(mock.dataObject, 'es') .then(e => { - expect(e).toEqual(transaltedES); + expect(e).toEqual(mock.transaltedES); }); }); diff --git a/__tests__/api/yandex.spec.js b/lib/__tests__/yandex.spec.js similarity index 80% rename from __tests__/api/yandex.spec.js rename to lib/__tests__/yandex.spec.js index 6829a27..de7b4c9 100644 --- a/__tests__/api/yandex.spec.js +++ b/lib/__tests__/yandex.spec.js @@ -1,6 +1,6 @@ // eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies -const {mockDataObject, transaltedES} = require('mock-data'); -const Translate = require('../../lib/translate-json-object'); +const Translate = require('../translate-json-object'); +const mock = require('../fixture/data.fixture'); const TJO = new Translate(); const init = jest.fn(TJO.init); @@ -9,10 +9,10 @@ const translate = jest.fn(TJO.translate); describe('TJO Yandex Translate Service', () => { it('Should transalte object: success', () => { init({yandexApiKey: 'apiToken'}); - return translate(mockDataObject, 'es') + return translate(mock.dataObject, 'es') .then(e => { expect(e).toBeDefined(); - expect(e).toEqual(transaltedES); + expect(e).toEqual(mock.transaltedES); }); }); diff --git a/__mocks__/mock-data.js b/lib/fixture/data.fixture.js similarity index 53% rename from __mocks__/mock-data.js rename to lib/fixture/data.fixture.js index c0049a1..4bd4e3c 100644 --- a/__mocks__/mock-data.js +++ b/lib/fixture/data.fixture.js @@ -1,8 +1,7 @@ - -const mockDataObject = {name: 'name', some: [{name: 'j'}], addressField: ['city', 'state', 'zipdecode'], bool: true, num: 33, badBool: false, nully: null, undefin: undefined}; +const dataObject = {name: 'name', some: [{name: 'j'}], addressField: ['city', 'state', 'zipdecode'], bool: true, num: 33, badBool: false, nully: null, undefin: undefined}; const transaltedES = {name: 'name-es', some: [{name: 'j-es'}], addressField: ['city-es', 'state-es', 'zipdecode-es'], bool: true, num: 33, badBool: false, nully: null, undefin: undefined}; module.exports = { - mockDataObject, + dataObject, transaltedES };