Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add ava, nyc, and sinon scenario tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 15, 2019
1 parent 5cc5619 commit ac5752d
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/fixture/scenario/ava-nyc-sinon/cwd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

process.chdir(__dirname)
1 change: 1 addition & 0 deletions test/fixture/scenario/ava-nyc-sinon/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (value) => console.log(value)
9 changes: 9 additions & 0 deletions test/fixture/scenario/ava-nyc-sinon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "ava-nyc-sinon",
"private": true,
"ava": {
"require": [
"../../../../"
]
}
}
11 changes: 11 additions & 0 deletions test/fixture/scenario/ava-nyc-sinon/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test from "ava"
import sinon from "sinon"
import log from "./log.js"

test("test", (t) => {
sinon.spy(console, "log")

log("a")

t.is(console.log.callCount, 1)
})
3 changes: 3 additions & 0 deletions test/fixture/scenario/ava-sinon/cwd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

process.chdir(__dirname)
9 changes: 9 additions & 0 deletions test/fixture/scenario/ava-sinon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "ava-sinon",
"private": true,
"ava": {
"require": [
"../../../../"
]
}
}
3 changes: 3 additions & 0 deletions test/fixture/scenario/ava-sinon/restring.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as ns from "./string.js"

export const recapitalize = (string) => ns.capitalize(string)
1 change: 1 addition & 0 deletions test/fixture/scenario/ava-sinon/string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1)
11 changes: 11 additions & 0 deletions test/fixture/scenario/ava-sinon/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test from "ava"
import { recapitalize } from "./restring.js"
import { stub } from "sinon"
import * as ns from "./string.js"

test("test", (t) => {
stub(ns, "capitalize").callsFake((string) => string.toUpperCase())

t.is(ns.capitalize("abc"), "ABC")
t.is(recapitalize("def"), "DEF")
})
23 changes: 23 additions & 0 deletions test/scenario-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,29 @@ describe("scenario tests", function () {
], envAuto)
})

it("should work with ava and sinon", () => {
const dirPath = path.resolve("fixture/scenario/ava-sinon")
const cwdPath = path.resolve(dirPath, "cwd.js")
const avaPattern = path.resolve(dirPath, "test.js")

return node([
"-r", cwdPath,
avaPath, avaPattern
], envAuto)
})

it("should work with ava, nyc, and sinon", () => {
const dirPath = path.resolve("fixture/scenario/ava-nyc-sinon")
const cwdPath = path.resolve(dirPath, "cwd.js")
const avaPattern = path.resolve(dirPath, "test.js")

return exec("nyc", [
"--cwd", dirPath,
"-i", cwdPath,
"ava", avaPattern
], envAuto)
})

it("should work with ava, nyc, and tsc", () => {
const dirPath = path.resolve("fixture/scenario/ava-nyc-tsc")
const cwdPath = path.resolve(dirPath, "cwd.js")
Expand Down

0 comments on commit ac5752d

Please sign in to comment.