Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should assign base context properties to itself', () => {
// Arrange
const context = new ContextMock(createPayload(createSha(), createSha(), {
action: 'synchronize',
repoName: 'jarrodldavis/probot-gpg-test',
number: 1
}), 'pull_request', uuid())
// Act
const gpgContext = new GpgEventContext(createLogStubs(), context)
// Assert
assert.equal(context.payload, gpgContext.payload)
assert.equal(context.github, gpgContext.github)
})
it('should throw if `acceptEvent` is called with incorrect execution context', async () => {
// Arrange
const { plugin, robotMock, contextMock } = arrange(sinon.stub())
plugin.on('error', sinon.stub())
plugin.load(robotMock)
// Act, Assert
const err = await assert.rejects(plugin.acceptEvent.call(undefined, contextMock))
assert.equal('Unexpected execution context for method call', err.message)
})
})
it('should return "failure" if a middle status is a failure', () => {
// Arrange
const statusChain = ['success', 'success', 'failure', 'success', 'success'];
// Act
const actual = reduceStatuses(contextMock, statusChain);
// Assert
assert.equal('failure', actual);
});
it('should return "failure" if commit is not verified', () => {
// Arrange
const commit = createCommit('failure');
// Act
const actual = validateCommit(contextMock, commit);
// Assert
assert.equal('failure', actual);
});
it('should return "success" if commit is verified', () => {
// Arrange
const commit = createCommit('success');
// Act
const actual = validateCommit(contextMock, commit);
// Assert
assert.equal('success', actual);
});
it('should throw if `acceptEvent` is called with incorrect execution context', async () => {
// Arrange
const { plugin, robotMock, contextMock } = arrange(sinon.stub())
plugin.on('error', sinon.stub())
plugin.load(robotMock)
// Act, Assert
const err = await assert.rejects(plugin.acceptEvent.call(undefined, contextMock))
assert.equal('Unexpected execution context for method call', err.message)
})
})
it('should throw if `load` is called with incorrect execution context', () => {
// Arrange
const { plugin, robotMock } = arrange(sinon.stub())
// Act, Assert
const err = assert.throws(() => plugin.load.call(undefined, robotMock))
assert.equal('Unexpected execution context for method call', err.message)
})
it('parses script', function() {
assert.equal('example/ok.js', this.page.script);
});
it('should return "failure" if one, but not all, of the commits has an invalid GPG signature', async () => {
return assert.equal('failure', await testScenario('success', 'failure', 'success'));
});
it('should return "success" if all of the commits have a verified GPG signature', async () => {
return assert.equal('success', await testScenario('success', 'success', 'success'));
});