Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(config-lerna-scopes): do not break tests in case of lerna update
  • Loading branch information
armano2 committed Feb 8, 2020
commit 74fedc5ec8a4176ce83e0dd566f25e211fabf5d7
13 changes: 7 additions & 6 deletions @commitlint/config-lerna-scopes/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ test('scope-enum does not throw for missing context', async () => {
const semverLt = jest.spyOn(semver, 'lt');
const {'scope-enum': fn} = config.rules;
await expect(fn()).resolves.toBeTruthy();
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});

test('scope-enum has expected severity', async () => {
const semverLt = jest.spyOn(semver, 'lt');
const {'scope-enum': fn} = config.rules;
const [severity] = await fn();
expect(severity).toBe(2);
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});

test('scope-enum has expected modifier', async () => {
const semverLt = jest.spyOn(semver, 'lt');
const {'scope-enum': fn} = config.rules;
const [, modifier] = await fn();
expect(modifier).toBe('always');
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});

test('returns empty value for empty lerna repository', async () => {
Expand All @@ -57,7 +57,7 @@ test('returns empty value for empty lerna repository', async () => {
const cwd = await lerna.bootstrap('empty', __dirname);
const [, , value] = await fn({cwd});
expect(value).toEqual([]);
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});

test('returns expected value for basic lerna repository', async () => {
Expand All @@ -67,7 +67,7 @@ test('returns expected value for basic lerna repository', async () => {

const [, , value] = await fn({cwd});
expect(value).toEqual(['a', 'b']);
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});

test('returns expected value for scoped lerna repository', async () => {
Expand All @@ -77,7 +77,7 @@ test('returns expected value for scoped lerna repository', async () => {

const [, , value] = await fn({cwd});
expect(value).toEqual(['a', 'b']);
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});

test('works with lerna version < 3', async () => {
Expand All @@ -86,4 +86,5 @@ test('works with lerna version < 3', async () => {
const cwd = await lerna.bootstrap('lerna-two', __dirname);
await expect(fn({cwd})).resolves.toBeTruthy();
expect(semverLt).toHaveBeenLastCalledWith('2.11.0', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(true);
});