mirror of
https://github.com/RamonGebben/mergify.git
synced 2026-03-10 08:51:18 +00:00
Mocking config fs
This commit is contained in:
@@ -6,6 +6,19 @@ const {
|
||||
const mock = require('mock-fs');
|
||||
|
||||
describe('utils/doFetch', () => {
|
||||
beforeEach(() => {
|
||||
const configPath = `${__dirname}/../../../.config`;
|
||||
const stub = {
|
||||
userId: 42,
|
||||
domain: 'gitlab.com',
|
||||
privateToken: '90809657890'
|
||||
};
|
||||
|
||||
mock({
|
||||
[configPath]: JSON.stringify(stub)
|
||||
});
|
||||
});
|
||||
|
||||
test('it can fetch', async() => {
|
||||
const mockResponse = [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
const fetch = require('node-fetch');
|
||||
const { getMergeRequests } = require('./index');
|
||||
const mock = require('mock-fs');
|
||||
|
||||
describe('utils/getMergeRequests', () => {
|
||||
beforeEach(() => {
|
||||
const configPath = `${__dirname}/../../../.config`;
|
||||
const stub = {
|
||||
userId: 42,
|
||||
domain: 'gitlab.com',
|
||||
privateToken: '90809657890'
|
||||
};
|
||||
|
||||
mock({
|
||||
[configPath]: JSON.stringify(stub)
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch merge requests', async() => {
|
||||
const mockResponse = [
|
||||
{
|
||||
@@ -15,4 +29,6 @@ describe('utils/getMergeRequests', () => {
|
||||
const mergeRequests = await getMergeRequests({});
|
||||
expect(mergeRequests).toEqual(mockResponse);
|
||||
});
|
||||
|
||||
afterEach(mock.restore);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user