forked from as-pect/as-pect
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
193 changed files
with
4,411 additions
and
2,936 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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,36 @@ | ||
import { parse } from "../src/cli/util/CommandLineArg"; | ||
import { createDefaultPerformanceConfiguration } from '../src/util/IPerformanceConfiguration'; | ||
|
||
|
||
|
||
describe("Command line parsing", () => { | ||
|
||
it("should match empty strings", () => {}); | ||
|
||
it("should fail if missing argument", () => { | ||
expect(() => parse(["-t"])).toThrow(); | ||
}); | ||
|
||
it("should change the default value", () => { | ||
let opts = parse(["-t", "testFile"]); | ||
expect(opts.test).toBe("testFile"); | ||
}); | ||
|
||
it("should handle enabling booleans", () => { | ||
let opts = parse(["--performance"]); | ||
expect(opts.performance.enabled).toBeTruthy() | ||
}); | ||
|
||
it("should handle setting booleans", () => { | ||
let opts = parse(["--performance=true"]); | ||
expect(opts.performance.enabled).toBeTruthy() | ||
}); | ||
|
||
it("should have correct defaults for performance", () => { | ||
expect(parse([]).performance).toStrictEqual(createDefaultPerformanceConfiguration()) | ||
}); | ||
|
||
it("should set option from alias", () => { | ||
expect(parse(["-v"]).version).toBeTruthy() | ||
}) | ||
}); |
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,50 @@ | ||
import { TestContext } from "../src/test/TestContext"; | ||
import { createLogModule } from "./setup/createLogModule"; | ||
|
||
let ctx: TestContext; | ||
|
||
let start = new Promise<void>((resolve, reject) => { | ||
createLogModule({}, (err, result) => { | ||
if (err) { | ||
console.log(err); | ||
reject(err); | ||
} else { | ||
ctx = result!; | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
beforeEach(() => start); | ||
|
||
describe("logged values", () => { | ||
test("log values", () => { | ||
for (const group of ctx.testGroups) { | ||
for (const log of group.logs) { | ||
expect(log.bytes).toMatchSnapshot(`${group.name} bytes`); | ||
expect(log.message).toMatchSnapshot(`${group.name} message`); | ||
expect(log.offset).toMatchSnapshot(`${group.name} offset`); | ||
expect(log.pointer).toMatchSnapshot(`${group.name} pointer`); | ||
expect(log.stack).toMatchSnapshot(`${group.name} stack`); | ||
expect(log.target).toBe(group); | ||
expect(log.value).toMatchSnapshot(`${group.name} snapshot`); | ||
} | ||
|
||
for (const test of group.tests) { | ||
for (const log of test.logs) { | ||
expect(log.bytes).toMatchSnapshot(`${group.name}~${test.name} bytes`); | ||
expect(log.message).toMatchSnapshot(`${group.name}~${test.name} message`); | ||
expect(log.offset).toMatchSnapshot(`${group.name}~${test.name} offset`); | ||
expect(log.pointer).toMatchSnapshot(`${group.name}~${test.name} pointer`); | ||
expect(log.stack).toMatchSnapshot(`${group.name}~${test.name} stack`); | ||
expect(log.target).toBe(test); | ||
expect(log.value).toMatchSnapshot(`${group.name}~${test.name} snapshot`); | ||
} | ||
} | ||
|
||
for (const todo of group.todos) { | ||
expect(todo).toMatchSnapshot(`${group.name} todo`); | ||
} | ||
} | ||
}); | ||
}); |
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,57 @@ | ||
import { TestContext } from "../src/test/TestContext"; | ||
import { createPassFailModule } from "./setup/createPassFailModule"; | ||
|
||
let ctx: TestContext; | ||
|
||
let start = new Promise<void>((resolve, reject) => { | ||
createPassFailModule({}, (err, result) => { | ||
if (err) { | ||
console.log(err); | ||
reject(err); | ||
} else { | ||
ctx = result!; | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
beforeAll(() => start); | ||
|
||
describe("pass-fail", () => { | ||
test("pass-fail", () => { | ||
for (const group of ctx.testGroups) { | ||
expect(group.pass).toMatchSnapshot(`${group.name} pass`); | ||
expect(group.afterAllPointers).toMatchSnapshot(`${group.name} afterAllPointers`); | ||
expect(group.afterEachPointers).toMatchSnapshot(`${group.name} afterEachPointers`); | ||
expect(group.beforeEachPointers).toMatchSnapshot(`${group.name} beforeEachPointers`); | ||
expect(group.beforeAllPointers).toMatchSnapshot(`${group.name} beforeAllPointers`); | ||
expect(group.reason).toMatchSnapshot(`${group.name} reason`); | ||
|
||
for (const test of group.tests) { | ||
expect(test.pass).toMatchSnapshot(`${group.name}~${test.name} pass`); | ||
if (test.actual) { | ||
expect(test.actual.bytes).toMatchSnapshot(`${group.name}~${test.name}~actual bytes`); | ||
expect(test.actual.message).toMatchSnapshot(`${group.name}~${test.name}~actual message`); | ||
expect(test.actual.offset).toMatchSnapshot(`${group.name}~${test.name}~actual offset`); | ||
expect(test.actual.pointer).toMatchSnapshot(`${group.name}~${test.name}~actual pointer`); | ||
expect(test.actual.stack).toMatchSnapshot(`${group.name}~${test.name}~actual stack`); | ||
expect(test.actual.target).toBe(test); | ||
expect(test.actual.value).toMatchSnapshot(`${group.name}~${test.name}~actual value`); | ||
} | ||
if (test.expected) { | ||
expect(test.expected.bytes).toMatchSnapshot(`${group.name}~${test.name}~expected bytes`); | ||
expect(test.expected.message).toMatchSnapshot(`${group.name}~${test.name}~expected message`); | ||
expect(test.expected.offset).toMatchSnapshot(`${group.name}~${test.name}~expected offset`); | ||
expect(test.expected.pointer).toMatchSnapshot(`${group.name}~${test.name}~expected pointer`); | ||
expect(test.expected.stack).toMatchSnapshot(`${group.name}~${test.name}~expected stack`); | ||
expect(test.expected.target).toBe(test); | ||
expect(test.expected.value).toMatchSnapshot(`${group.name}~${test.name}~expected value`); | ||
expect(test.expected.negated).toMatchSnapshot(`${group.name}~${test.name}~expected negated`); | ||
} | ||
expect(test.functionPointer).toMatchSnapshot(`${group.name}~${test.name} functionPointer`); | ||
expect(test.message).toMatchSnapshot(`${group.name}~${test.name} message`); | ||
expect(test.negated).toMatchSnapshot(`${group.name}~${test.name} negated`); | ||
} | ||
} | ||
}); | ||
}); |
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,34 @@ | ||
import { TestContext } from "../src/test/TestContext"; | ||
import { createPerformanceModule } from "./setup/createPerformanceModule"; | ||
|
||
let ctx: TestContext; | ||
|
||
let start = new Promise<void>((resolve, reject) => { | ||
createPerformanceModule({}, (err, result) => { | ||
if (err) { | ||
console.log(err); | ||
reject(err); | ||
} else { | ||
ctx = result!; | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
beforeAll(() => start); | ||
|
||
describe("pass-fail", () => { | ||
test("pass-fail", () => { | ||
for (const group of ctx.testGroups) { | ||
for (const test of group.tests) { | ||
expect(test.performance).toMatchSnapshot(`${group.name}~${test.name} performance`); | ||
expect(test.hasAverage).toMatchSnapshot(`${group.name}~${test.name} hasAverage`); | ||
expect(test.hasMedian).toMatchSnapshot(`${group.name}~${test.name} hasMedian`); | ||
expect(test.hasMin).toMatchSnapshot(`${group.name}~${test.name} hasMin`); | ||
expect(test.hasMax).toMatchSnapshot(`${group.name}~${test.name} hasMax`); | ||
expect(test.hasStdDev).toMatchSnapshot(`${group.name}~${test.name} hasStdDev`); | ||
expect(test.hasVariance).toMatchSnapshot(`${group.name}~${test.name} hasVariance`); | ||
} | ||
} | ||
}); | ||
}); |
File renamed without changes.
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
Oops, something went wrong.