Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: normalize package was broken #758
- Loading branch information
1 parent
84d859c
commit 3717ad4
Showing
2 changed files
with
50 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// @flow | ||
|
||
import {DEFAULT_REVISION, normalizePackage} from "../../src/lib/storage-utils"; | ||
import {DIST_TAGS} from "../../src/lib/utils"; | ||
import {readFile} from "../functional/lib/test.utils"; | ||
|
||
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`); | ||
|
||
describe('Storage Utils', () => { | ||
test('normalizePackage clean', () => { | ||
const pkg = normalizePackage({ | ||
_attachments: {}, | ||
_distfiles: {}, | ||
_rev: '', | ||
_uplinks: {}, | ||
name: '', | ||
versions: {}, | ||
[DIST_TAGS]: {}, | ||
}); | ||
expect(pkg).toBeDefined(); | ||
expect(pkg.time).toBeInstanceOf(Object); | ||
expect(pkg.versions).toBeInstanceOf(Object); | ||
expect(pkg[DIST_TAGS]).toBeInstanceOf(Object); | ||
expect(pkg._distfiles).toBeInstanceOf(Object); | ||
expect(pkg._attachments).toBeInstanceOf(Object); | ||
expect(pkg._uplinks).toBeInstanceOf(Object); | ||
}); | ||
|
||
test('normalizePackage partial metadata', () => { | ||
const pkg = normalizePackage(readMetadata('metadata')); | ||
expect(pkg).toBeDefined(); | ||
expect(pkg.time).toBeInstanceOf(Object); | ||
expect(pkg.versions).toBeInstanceOf(Object); | ||
expect(pkg[DIST_TAGS]).toBeInstanceOf(Object); | ||
expect(pkg._distfiles).toBeInstanceOf(Object); | ||
expect(pkg._attachments).toBeInstanceOf(Object); | ||
expect(pkg._uplinks).toBeInstanceOf(Object); | ||
}); | ||
|
||
test('normalizePackage partial default revision', () => { | ||
const pkg = normalizePackage(readMetadata('metadata')); | ||
expect(pkg).toBeDefined(); | ||
expect(pkg._rev).toBeDefined(); | ||
expect(pkg._rev).toBe(DEFAULT_REVISION); | ||
}); | ||
}); |