Skip to content

Commit

Permalink
Merge 092fa73 into 943f31d
Browse files Browse the repository at this point in the history
  • Loading branch information
jtenner committed Jun 21, 2019
2 parents 943f31d + 092fa73 commit c688beb
Show file tree
Hide file tree
Showing 193 changed files with 4,411 additions and 2,936 deletions.
532 changes: 259 additions & 273 deletions readme.md → README.md

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions __tests__/CommandLineArg.spec.ts
@@ -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()
})
});
20 changes: 11 additions & 9 deletions __tests__/PerformanceConfiguration.spec.ts
Expand Up @@ -16,18 +16,20 @@ let start = new Promise<void>((resolve, reject) => {
});
});

type PartialConfiguration = Partial<IPerformanceConfiguration>


describe("Performance Configuration", () => {
it("should have no warings if maxSamples configured correctly", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
maxSamples: 1000
};
const context: TestContext = new TestContext({ performanceConfiguration });
expect(context.warnings).toHaveLength(0);
});

it("should have warnings if configured to run less than 0 max samples", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
maxSamples: -1
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand All @@ -39,7 +41,7 @@ describe("Performance Configuration", () => {
});

it("should have warnings if configured to run less than allowed max samples", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
maxSamples: 999999999999999
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand All @@ -50,7 +52,7 @@ describe("Performance Configuration", () => {
});

it("should have warnings if configured maxTestRuntime is too large", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
maxTestRunTime: 999999999999999
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand All @@ -61,7 +63,7 @@ describe("Performance Configuration", () => {
});

it("should have warnings if configured maxTestRuntime is too negative", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
maxTestRunTime: -1
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand All @@ -72,15 +74,15 @@ describe("Performance Configuration", () => {
});

it("should have not warnings if configured maxTestRuntime is configured correctly", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
maxTestRunTime: 500
};
const context: TestContext = new TestContext({ performanceConfiguration });
expect(context.warnings).toHaveLength(0);
});

it("should have warnings if configured decimalPlaces is too large", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
roundDecimalPlaces: 100
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand All @@ -91,7 +93,7 @@ describe("Performance Configuration", () => {
});

it("should have warnings if configured decimalPlaces is negative", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
roundDecimalPlaces: -1
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand All @@ -102,7 +104,7 @@ describe("Performance Configuration", () => {
});

it("should have not warnings if configured decimalPlaces is configured correctly", () => {
const performanceConfiguration: IPerformanceConfiguration = {
const performanceConfiguration: PartialConfiguration = {
roundDecimalPlaces: 3
};
const context: TestContext = new TestContext({ performanceConfiguration });
Expand Down
50 changes: 50 additions & 0 deletions __tests__/TestContext.log.spec.ts
@@ -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`);
}
}
});
});
57 changes: 57 additions & 0 deletions __tests__/TestContext.pass-fail.spec.ts
@@ -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`);
}
}
});
});
34 changes: 34 additions & 0 deletions __tests__/TestContext.performance.spec.ts
@@ -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.
1 change: 1 addition & 0 deletions __tests__/TestResult.spec.ts
Expand Up @@ -5,6 +5,7 @@ let t: TestResult;
describe("TestResult", (): void => {
beforeEach((): void => {
t = new TestResult();
t.performance = true;
for (let i = 0; i < 1000; i++) {
t.times.push(i);
}
Expand Down

0 comments on commit c688beb

Please sign in to comment.