-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
switch source to ESM, migrate off Jest to UVU, drop Node 16
Showing
15 changed files
with
134 additions
and
2,756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { test } from 'uvu'; | ||
import { is } from 'uvu/assert'; | ||
|
||
import { diffLocks, STATUS, countStatuses, parseLock } from '../../src/utils.mjs'; | ||
import { getTestLockContent } from '../testUtils.mjs'; | ||
|
||
test('Yarn Classic - detect changes', () => { | ||
const contentA = getTestLockContent('classic-downgrade', 'a.lock'); | ||
const contentB = getTestLockContent('classic-downgrade', 'b.lock'); | ||
|
||
const result = diffLocks(parseLock(contentA), parseLock(contentB)); | ||
|
||
is(Object.keys(result).length, 52); | ||
|
||
is(countStatuses(result, STATUS.ADDED), 3); | ||
is(countStatuses(result, STATUS.UPDATED), 49); | ||
is(countStatuses(result, STATUS.DOWNGRADED), 0); | ||
is(countStatuses(result, STATUS.REMOVED), 0); | ||
}); | ||
|
||
test('Yarn Classic - no downgrade detected, multiple cases', () => { | ||
const contentA = getTestLockContent('classic-downgrade-complex', 'a.lock'); | ||
const contentB = getTestLockContent('classic-downgrade-complex', 'b.lock'); | ||
|
||
const result = diffLocks(parseLock(contentA), parseLock(contentB)); | ||
|
||
is(Object.keys(result).length, 389); | ||
|
||
is(countStatuses(result, STATUS.ADDED), 357); | ||
is(countStatuses(result, STATUS.UPDATED), 32); | ||
is(countStatuses(result, STATUS.DOWNGRADED), 0); | ||
is(countStatuses(result, STATUS.REMOVED), 0); | ||
}); | ||
|
||
test('Yarn Berry (v2) - detect changes', () => { | ||
const contentA = getTestLockContent('berry-v2', 'a.lock'); | ||
const contentB = getTestLockContent('berry-v2', 'b.lock'); | ||
|
||
const result = diffLocks(parseLock(contentA), parseLock(contentB)); | ||
|
||
is(Object.keys(result).length, 6); | ||
|
||
is(countStatuses(result, STATUS.ADDED), 1); | ||
is(countStatuses(result, STATUS.UPDATED), 4); | ||
is(countStatuses(result, STATUS.DOWNGRADED), 0); | ||
is(countStatuses(result, STATUS.REMOVED), 1); | ||
}); | ||
|
||
test('Yarn Berry (v3) - detect changes', () => { | ||
const contentA = getTestLockContent('berry-v3', 'a.lock'); | ||
const contentB = getTestLockContent('berry-v3', 'b.lock'); | ||
|
||
const result = diffLocks(parseLock(contentA), parseLock(contentB)); | ||
|
||
is(Object.keys(result).length, 7); | ||
|
||
is(countStatuses(result, STATUS.ADDED), 1); | ||
is(countStatuses(result, STATUS.UPDATED), 5); | ||
is(countStatuses(result, STATUS.DOWNGRADED), 0); | ||
is(countStatuses(result, STATUS.REMOVED), 1); | ||
}); | ||
|
||
test.run(); |