Skip to content

Commit

Permalink
fix before tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crookse committed Jun 22, 2020
1 parent e10954f commit e55e069
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
12 changes: 6 additions & 6 deletions tests/integration/hooks/before_all_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import { Rhum } from "../../../mod.ts";
let suite_val = "Ed";
let case_val = 22;

Rhum.testPlan("app_test.ts", () => {
Rhum.testPlan("before_all_test.ts", () => {
Rhum.beforeAll(() => {
suite_val = "Eric";
});
// Run the first test suite
Rhum.testSuite("run()", () => {
Rhum.testSuite("test suite 1", () => {
Rhum.beforeAll(() => {
case_val = 2;
});
Rhum.testCase("Returns true", () => {
Rhum.testCase("hooks properly set suite_val and case_val", () => {
// Asserting the value has changed
Rhum.asserts.assertEquals(suite_val, "Eric");
// Revert it back for the next test that uses it
Expand All @@ -25,18 +25,18 @@ Rhum.testPlan("app_test.ts", () => {
Rhum.asserts.assertEquals(case_val, 2);
case_val = 22;
});
Rhum.testCase("Returns false", () => {
Rhum.testCase("hooks properly set case_val", () => {
// Assert the value has changed from 22 to 2 (after setting it to 22 in the above case)
Rhum.asserts.assertEquals(case_val, 2);
});
});

// Run the second test suite
Rhum.testSuite("close()", () => {
Rhum.testSuite("test suite 2", () => {
Rhum.beforeAll(() => {
case_val = 0;
});
Rhum.testCase("Returns true", async () => {
Rhum.testCase("hooks properly set suite_val and case_val", async () => {
// Asserting the hook should have replaced the name
Rhum.asserts.assertEquals(suite_val, "Eric");
suite_val = "Ed";
Expand Down
24 changes: 17 additions & 7 deletions tests/integration/hooks/before_each_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,49 @@
* Purpose of this test is to ensure a test using before_each succeeds
*/

import { Rhum } from "../../mod.ts";
import { Rhum } from "../../../mod.ts";

let suite_val = "Ed";
let case_val = 22;

Rhum.testPlan("app_test.ts", () => {
Rhum.testPlan("before_each_test.", () => {
Rhum.beforeEach(() => {
suite_val = "Eric";
});
// Run the first test suite
Rhum.testSuite("run()", () => {
Rhum.testSuite("test suite 1", () => {
Rhum.beforeEach(() => {
case_val = 2;
});
Rhum.testCase("Returns true", () => {
Rhum.testCase("suite_val is Eric", () => {
Rhum.asserts.assertEquals(suite_val, "Eric");
suite_val = "Ed";
});
Rhum.testCase("suite_val is still Eric", () => {
Rhum.asserts.assertEquals(suite_val, "Eric");
});
Rhum.testCase("case_val is 2", () => {
Rhum.asserts.assertEquals(case_val, 2);
case_val = 22;
});
Rhum.testCase("Returns false", () => {
Rhum.testCase("case_val is still 2", () => {
Rhum.asserts.assertEquals(case_val, 2);
});
});

// Run the second test suite
Rhum.testSuite("close()", () => {
Rhum.testSuite("test suite 2", () => {
Rhum.beforeEach(() => {
case_val = 0;
});
Rhum.testCase("Returns true", async () => {
Rhum.testCase("suite_val is Eric", async () => {
Rhum.asserts.assertEquals(suite_val, "Eric");
suite_val = "Ed";
});
Rhum.testCase("suite_val is still Eric", async () => {
Rhum.asserts.assertEquals(suite_val, "Eric");
});
Rhum.testCase("case_val is 0", () => {
Rhum.asserts.assertEquals(case_val, 0);
});
});
Expand Down

0 comments on commit e55e069

Please sign in to comment.