semantic-release/test/verify-pkg.test.js
2017-10-29 14:37:05 -07:00

33 lines
1.2 KiB
JavaScript

import test from 'ava';
import SemanticReleaseError from '@semantic-release/error';
import verify from '../src/lib/verify-pkg';
test('Verify name and repository', t => {
// Call the verify module with package
t.notThrows(() => verify({name: 'package', repository: {url: 'http://github.com/whats/up.git'}}));
});
test('Return error for missing package name', t => {
// Call the verify module with package
const error = t.throws(() => verify({repository: {url: 'http://github.com/whats/up.git'}}));
// Verify error code and type
t.is(error.code, 'ENOPKGNAME');
t.true(error instanceof SemanticReleaseError);
});
test('Return error for missing repository', t => {
// Call the verify module with package
const error = t.throws(() => verify({name: 'package'}));
// Verify error code and type
t.is(error.code, 'ENOPKGREPO');
t.true(error instanceof SemanticReleaseError);
});
test('Return error for missing repository url', t => {
// Call the verify module with package
const error = t.throws(() => verify({name: 'package', repository: {}}));
// Verify error code and type
t.is(error.code, 'ENOPKGREPO');
t.true(error instanceof SemanticReleaseError);
});