Skip to content
This repository was archived by the owner on Apr 18, 2022. It is now read-only.

Commit af5ef32

Browse files
authored
Merge pull request #27 from udibo/dev
Remove dependencies
2 parents ea2dcbd + 66fa4e9 commit af5ef32

File tree

6 files changed

+22
-25
lines changed

6 files changed

+22
-25
lines changed

deps.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

describe_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
assertEquals,
44
assertObjectMatch,
55
assertStrictEquals,
6-
} from "./deps.ts";
6+
} from "./test_deps.ts";
77
import {
88
afterAll,
99
afterEach,

examples/user_flat_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from "../mod.ts";
2-
import { assertEquals } from "../deps.ts";
2+
import { assertEquals } from "../test_deps.ts";
33
import { getUser, resetUsers, User } from "./user.ts";
44

55
interface UserContext {

examples/user_nested_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterEach, beforeEach, describe, it } from "../mod.ts";
2-
import { assertEquals } from "../deps.ts";
2+
import { assertEquals } from "../test_deps.ts";
33
import { getUser, resetUsers, User } from "./user.ts";
44

55
describe("user describe", () => {

test_deps.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
export { delay } from "https://deno.land/std@0.128.0/async/delay.ts";
2+
export {
3+
assert,
4+
assertEquals,
5+
AssertionError,
6+
assertObjectMatch,
7+
assertRejects,
8+
assertStrictEquals,
9+
assertThrows,
10+
} from "https://deno.land/std@0.128.0/testing/asserts.ts";
11+
112
export {
213
assertSpyCall,
314
assertSpyCallAsync,

test_suite.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Vector } from "./deps.ts";
2-
31
/** The options for creating a test suite with the describe function. */
42
export interface DescribeDefinition<T> extends Omit<Deno.TestDefinition, "fn"> {
53
fn?: () => void;
@@ -56,12 +54,12 @@ const optionalTestStepDefinitionKeys: (keyof Deno.TestStepDefinition)[] = [
5654
*/
5755
export class TestSuite<T> {
5856
protected describe: DescribeDefinition<T>;
59-
protected steps: Vector<TestSuite<T> | ItDefinition<T>>;
57+
protected steps: (TestSuite<T> | ItDefinition<T>)[];
6058
protected hasOnlyStep: boolean;
6159

6260
constructor(describe: DescribeDefinition<T>) {
6361
this.describe = describe;
64-
this.steps = new Vector();
62+
this.steps = [];
6563
this.hasOnlyStep = false;
6664

6765
const suite: TestSuite<T> = describe.suite ??
@@ -130,14 +128,14 @@ export class TestSuite<T> {
130128

131129
/** The stack of tests that are actively running. */
132130
// deno-lint-ignore no-explicit-any
133-
static active: Vector<TestSuite<any>> = new Vector();
131+
static active: TestSuite<any>[] = [];
134132

135133
/** This is used internally for testing this module. */
136134
static reset(): void {
137135
TestSuite.running = false;
138136
TestSuite.started = false;
139137
TestSuite.current = null;
140-
TestSuite.active = new Vector();
138+
TestSuite.active = [];
141139
}
142140

143141
/** This is used internally to register tests. */
@@ -153,14 +151,14 @@ export class TestSuite<T> {
153151
static addingOnlyStep<T>(suite: TestSuite<T>) {
154152
if (!suite.hasOnlyStep) {
155153
for (let i = 0; i < suite.steps.length; i++) {
156-
const step = suite.steps.get(i)!;
154+
const step = suite.steps[i]!;
157155
if (step instanceof TestSuite) {
158156
if (!(step.hasOnlyStep || step.describe.only)) {
159-
suite.steps.delete(i--);
157+
suite.steps.splice(i--, 1);
160158
}
161159
} else {
162160
if (!step.only) {
163-
suite.steps.delete(i--);
161+
suite.steps.splice(i--, 1);
164162
}
165163
}
166164
}
@@ -267,7 +265,7 @@ export class TestSuite<T> {
267265
context: T,
268266
activeIndex = 0,
269267
) {
270-
const suite: TestSuite<T> | undefined = TestSuite.active.get(activeIndex);
268+
const suite: TestSuite<T> | undefined = TestSuite.active[activeIndex];
271269
if (suite) {
272270
context = { ...context };
273271
if (suite.describe.beforeEach) {

0 commit comments

Comments
 (0)