From 596c727a35f872c8100f75392796ab6d4d6a3ed2 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Mon, 20 May 2019 07:33:39 +0200 Subject: [PATCH] test: relocate notification test --- .../modules/{ => notifications}/notify.spec.js | 14 +++++++------- .../request.spec.js} | 14 +++++++------- .../headers.auth.spec.js} | 10 +++++----- 3 files changed, 19 insertions(+), 19 deletions(-) rename test/unit/modules/{ => notifications}/notify.spec.js (85%) rename test/unit/modules/{notify-request.spec.js => notifications/request.spec.js} (84%) rename test/unit/modules/{uplink.auth.spec.js => uplinks/headers.auth.spec.js} (93%) diff --git a/test/unit/modules/notify.spec.js b/test/unit/modules/notifications/notify.spec.js similarity index 85% rename from test/unit/modules/notify.spec.js rename to test/unit/modules/notifications/notify.spec.js index e55ab7c9c..31938c68b 100644 --- a/test/unit/modules/notify.spec.js +++ b/test/unit/modules/notifications/notify.spec.js @@ -1,16 +1,16 @@ // @flow -import {parseConfigurationFile} from '../__helper'; -import {parseConfigFile} from '../../../src/lib/utils'; -import {notify} from '../../../src/lib/notify'; +import {parseConfigurationFile} from '../../__helper'; +import {parseConfigFile} from '../../../../src/lib/utils'; +import {notify} from '../../../../src/lib/notify'; -import {notifyRequest} from '../../../src/lib/notify/notify-request'; +import {notifyRequest} from '../../../../src/lib/notify/notify-request'; -jest.mock('./../../../src/lib/notify/notify-request', () => ({ +jest.mock('./../../../../src/lib/notify/notify-request', () => ({ notifyRequest: jest.fn((options, content) => Promise.resolve([options, content])) })); -require('../../../src/lib/logger').setup([]); +require('../../../../src/lib/logger').setup([]); const parseConfigurationNotifyFile = (name) => { return parseConfigurationFile(`notify/${name}`); @@ -21,7 +21,7 @@ const packagePatternNotificationConfig = parseConfigFile(parseConfigurationNotif const multiNotificationConfig = parseConfigFile(parseConfigurationNotifyFile('multiple.notify')); -describe('Notify', () => { +describe('Notifications:: Notify', () => { beforeEach(() => { jest.clearAllMocks(); diff --git a/test/unit/modules/notify-request.spec.js b/test/unit/modules/notifications/request.spec.js similarity index 84% rename from test/unit/modules/notify-request.spec.js rename to test/unit/modules/notifications/request.spec.js index 8ce33e981..78bcb032a 100644 --- a/test/unit/modules/notify-request.spec.js +++ b/test/unit/modules/notifications/request.spec.js @@ -2,7 +2,7 @@ * @prettier */ -import { HTTP_STATUS, API_ERROR } from '../../../src/lib/constants'; +import { HTTP_STATUS, API_ERROR } from '../../../../src/lib/constants'; /** * Mocks Logger Service @@ -14,7 +14,7 @@ const logger = { info: jest.fn(), }, }; -jest.doMock('../../../src/lib/logger', () => logger); +jest.doMock('../../../../src/lib/logger', () => logger); /** * Test Data @@ -24,7 +24,7 @@ const options = { }; const content = 'Verdaccio@x.x.x successfully published'; -describe('notifyRequest', () => { +describe('Notifications:: notifyRequest', () => { beforeEach(() => { jest.resetModules(); }); @@ -40,7 +40,7 @@ describe('notifyRequest', () => { resolver(error, response); }); - const notification = require('../../../src/lib/notify/notify-request'); + const notification = require('../../../../src/lib/notify/notify-request'); const args = [{ errorMessage: 'bad data' }, 'notify service has thrown an error: @{errorMessage}']; await expect(notification.notifyRequest(options, content)).rejects.toEqual(API_ERROR.BAD_DATA); @@ -57,7 +57,7 @@ describe('notifyRequest', () => { resolver(null, response); }); - const notification = require('../../../src/lib/notify/notify-request'); + const notification = require('../../../../src/lib/notify/notify-request'); const args = [{ errorMessage: 'bad data' }, 'notify service has thrown an error: @{errorMessage}']; await expect(notification.notifyRequest(options, content)).rejects.toEqual(API_ERROR.BAD_DATA); @@ -74,7 +74,7 @@ describe('notifyRequest', () => { resolver(null, response, response.body); }); - const notification = require('../../../src/lib/notify/notify-request'); + const notification = require('../../../../src/lib/notify/notify-request'); const infoArgs = [{ content }, 'A notification has been shipped: @{content}']; const debugArgs = [{ body: 'Successfully delivered' }, ' body: @{body}']; @@ -92,7 +92,7 @@ describe('notifyRequest', () => { resolver(null, response); }); - const notification = require('../../../src/lib/notify/notify-request'); + const notification = require('../../../../src/lib/notify/notify-request'); const infoArgs = [{ content }, 'A notification has been shipped: @{content}']; await expect(notification.notifyRequest(options, content)).rejects.toThrow('body is missing'); diff --git a/test/unit/modules/uplink.auth.spec.js b/test/unit/modules/uplinks/headers.auth.spec.js similarity index 93% rename from test/unit/modules/uplink.auth.spec.js rename to test/unit/modules/uplinks/headers.auth.spec.js index ab0dccb5c..9050b97d4 100644 --- a/test/unit/modules/uplink.auth.spec.js +++ b/test/unit/modules/uplinks/headers.auth.spec.js @@ -1,7 +1,7 @@ -import ProxyStorage from '../../../src/lib/up-storage'; -import {ERROR_CODE, TOKEN_BASIC, TOKEN_BEARER, DEFAULT_REGISTRY, HEADERS} from "../../../src/lib/constants"; -import {buildToken} from "../../../src/lib/utils"; -import {setup} from '../../../src/lib/logger'; +import ProxyStorage from '../../../../src/lib/up-storage'; +import {ERROR_CODE, TOKEN_BASIC, TOKEN_BEARER, DEFAULT_REGISTRY, HEADERS} from "../../../../src/lib/constants"; +import {buildToken} from "../../../../src/lib/utils"; +import {setup} from '../../../../src/lib/logger'; setup([]); @@ -22,7 +22,7 @@ function setHeaders(config, headers) { }); } -describe('uplink auth test', () => { +describe('uplink headers auth test', () => { test('if set headers empty should return default headers', () => { const headers = setHeaders();