Skip to content

Commit

Permalink
Add tests for parse-lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Feb 19, 2019
1 parent 5d89260 commit 20ffc92
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/functions/parse-lockfile.js
@@ -0,0 +1,40 @@
import expect from "expect"
import sinon from "sinon"
import parseLockfile from "../../functions/parse-lockfile"

describe("functions/parse-lockfile", () => {
afterEach(() => sinon.restore())
it("dislikes non-json", async () => {
let exit = sinon.stub(process, "exit")
expect(exit.called).toBe(false)
await parseLockfile("{")
expect(exit.called).toBe(true)
})

it("dislikes non-lockfile json", async () => {
let exit = sinon.stub(process, "exit")
expect(exit.called).toBe(false)
await parseLockfile("{a: []}")
expect(exit.called).toBe(true)
})

it("likes a lockfile", async () => {
let exit = sinon.stub(process, "exit")
expect(exit.called).toBe(false)
let lockfile = await parseLockfile(`
{
"name": "lil-yeet",
"lockfileVersion": 1,
"requires": true,
"dependencies": {}
}
`)
expect(exit.called).toBe(false)
expect(lockfile).toEqual({
name: "lil-yeet",
lockfileVersion: 1,
requires: true,
dependencies: {}
})
})
})

0 comments on commit 20ffc92

Please sign in to comment.