Skip to content

Instantly share code, notes, and snippets.

@TsuyoshiUshio
Last active July 29, 2019 18:13
Show Gist options
  • Save TsuyoshiUshio/d135dc1e64ba04b456d8d8d262b772a8 to your computer and use it in GitHub Desktop.
Save TsuyoshiUshio/d135dc1e64ba04b456d8d8d262b772a8 to your computer and use it in GitHub Desktop.
Mock by myself strategy sample
import * as assert from 'assert';
import * as sinon from 'sinon';
import rewiremock from 'rewiremock';
import { should as Should, expect } from 'chai';
import { IGitApi, GitApi } from 'azure-devops-node-api/GitApi';
import * as GitInterfaces from "azure-devops-node-api/interfaces/GitInterfaces";
var should = Should();
let debugMessages: string[] = [];
let variables: {[key: string]: string} = {};
let inputs: {[key: string]: string} = {};
rewiremock('azure-pipelines-task-lib')
.with({
'debug': sinon.stub().callsFake(m => debugMessages.push(m)),
'getInput': sinon.stub().callsFake(i => { return inputs[i] || null; }),
'getVariable': sinon.stub().callsFake(v => { return variables[v] || null; }),
'getEndpointAuthorizationParameter': () => "fooPAT",
'loc': sinon.stub().returnsArg(0)
});
rewiremock.enable();
import { IClientFactory, CreatePRCommentTask } from '../Src/task';
:
rewiremock.disable();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment