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

Commit 08f50f4

Browse files
authored
Merge pull request #34 from udibo/dev
Fix nested only option only applying to current suite
2 parents a8b5e81 + d232638 commit 08f50f4

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Test Suite
22

3-
[![version](https://img.shields.io/badge/release-0.14.0-success)](https://deno.land/x/test_suite@0.14.0)
4-
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/test_suite@0.14.0/mod.ts)
3+
[![version](https://img.shields.io/badge/release-0.15.0-success)](https://deno.land/x/test_suite@0.15.0)
4+
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/test_suite@0.15.0/mod.ts)
55
[![CI](https://github.com/udibo/test_suite/workflows/CI/badge.svg)](https://github.com/udibo/test_suite/actions?query=workflow%3ACI)
66
[![codecov](https://codecov.io/gh/udibo/test_suite/branch/main/graph/badge.svg?token=EFKGY72AAV)](https://codecov.io/gh/udibo/test_suite)
77
[![license](https://img.shields.io/github/license/udibo/test_suite)](https://github.com/udibo/test_suite/blob/master/LICENSE)
@@ -26,12 +26,12 @@ also be imported directly from GitHub using raw content URLs.
2626

2727
```ts
2828
// Import from Deno's third party module registry
29-
import { describe, it } from "https://deno.land/x/test_suite@0.14.0/mod.ts";
29+
import { describe, it } from "https://deno.land/x/test_suite@0.15.0/mod.ts";
3030
// Import from GitHub
3131
import {
3232
describe,
3333
it,
34-
} from "https://raw.githubusercontent.com/udibo/test_suite/0.14.0/mod.ts";
34+
} from "https://raw.githubusercontent.com/udibo/test_suite/0.15.0/mod.ts";
3535
```
3636

3737
## Usage
@@ -54,7 +54,7 @@ except they are called before and after each individual test.
5454
Below are some examples of how to use `describe` and `it` in tests.
5555

5656
See
57-
[deno docs](https://doc.deno.land/https/deno.land/x/test_suite@0.14.0/mod.ts)
57+
[deno docs](https://doc.deno.land/https/deno.land/x/test_suite@0.15.0/mod.ts)
5858
for more information.
5959

6060
### Nested test grouping
@@ -67,13 +67,13 @@ import {
6767
beforeEach,
6868
describe,
6969
it,
70-
} from "https://deno.land/x/test_suite@0.14.0/mod.ts";
71-
import { assertEquals } from "https://deno.land/std@0.130.0/testing/asserts.ts";
70+
} from "https://deno.land/x/test_suite@0.15.0/mod.ts";
71+
import { assertEquals } from "https://deno.land/std@0.133.0/testing/asserts.ts";
7272
import {
7373
getUser,
7474
resetUsers,
7575
User,
76-
} from "https://deno.land/x/test_suite@0.14.0/examples/user.ts";
76+
} from "https://deno.land/x/test_suite@0.15.0/examples/user.ts";
7777

7878
describe("user describe", () => {
7979
let user: User;
@@ -131,13 +131,13 @@ test result: ok. 1 passed (5 steps); 0 failed; 0 ignored; 0 measured; 0 filtered
131131
The example below can be found [here](examples/user_flat_test.ts).
132132

133133
```ts
134-
import { describe, it } from "https://deno.land/x/test_suite@0.14.0/mod.ts";
135-
import { assertEquals } from "https://deno.land/std@0.130.0/testing/asserts.ts";
134+
import { describe, it } from "https://deno.land/x/test_suite@0.15.0/mod.ts";
135+
import { assertEquals } from "https://deno.land/std@0.133.0/testing/asserts.ts";
136136
import {
137137
getUser,
138138
resetUsers,
139139
User,
140-
} from "https://deno.land/x/test_suite@0.14.0/examples/user.ts";
140+
} from "https://deno.land/x/test_suite@0.15.0/examples/user.ts";
141141

142142
interface UserContext {
143143
user: User;

describe_test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ Deno.test("global", async (t) => {
116116
assertSpyCalls(fns[0], 0);
117117
assertSpyCalls(fns[1], 0);
118118

119-
const call = assertSpyCall(test, 0);
119+
assertSpyCall(test, 0);
120+
const call = test.calls[0];
120121
const options = call.args[0] as Deno.TestDefinition;
121122
assertEquals(Object.keys(options).sort(), ["fn", "name"]);
122123
assertEquals(options.name, "global");
@@ -164,7 +165,8 @@ Deno.test("global", async (t) => {
164165
cb(fn);
165166

166167
assertSpyCalls(fn, 0);
167-
const call = assertSpyCall(test, 0);
168+
assertSpyCall(test, 0);
169+
const call = test.calls[0];
168170
const options = call.args[0] as Deno.TestDefinition;
169171
assertEquals(
170172
Object.keys(options).sort(),
@@ -632,7 +634,8 @@ Deno.test("global", async (t) => {
632634
try {
633635
cb(fns);
634636

635-
const call = assertSpyCall(test, 0);
637+
assertSpyCall(test, 0);
638+
const call = test.calls[0];
636639
const options = call.args[0] as Deno.TestDefinition;
637640
assertEquals(
638641
Object.keys(options).sort(),
@@ -1237,7 +1240,8 @@ Deno.test("global", async (t) => {
12371240
try {
12381241
cb(fns);
12391242

1240-
const call = assertSpyCall(test, 0);
1243+
assertSpyCall(test, 0);
1244+
const call = test.calls[0];
12411245
const options = call.args[0] as Deno.TestDefinition;
12421246
assertEquals(
12431247
Object.keys(options).sort(),
@@ -1342,7 +1346,8 @@ Deno.test("global", async (t) => {
13421346
assertSpyCalls(fns[0], 0);
13431347
assertSpyCalls(fns[1], 0);
13441348

1345-
const call = assertSpyCall(test, 0);
1349+
assertSpyCall(test, 0);
1350+
const call = test.calls[0];
13461351
const options = call.args[0] as Deno.TestDefinition;
13471352
assertEquals(Object.keys(options).sort(), ["fn", "name"]);
13481353
assertEquals(options.name, "example");
@@ -1448,7 +1453,8 @@ Deno.test("global", async (t) => {
14481453
assertSpyCalls(fns[0], 0);
14491454
assertSpyCalls(fns[1], 0);
14501455

1451-
const call = assertSpyCall(test, 0);
1456+
assertSpyCall(test, 0);
1457+
const call = test.calls[0];
14521458
const options = call.args[0] as Deno.TestDefinition;
14531459
assertEquals(Object.keys(options).sort(), ["fn", "name"]);
14541460
assertEquals(options.name, "example");
@@ -1554,7 +1560,8 @@ Deno.test("global", async (t) => {
15541560
assertSpyCalls(fns[0], 0);
15551561
assertSpyCalls(fns[1], 0);
15561562

1557-
const call = assertSpyCall(test, 0);
1563+
assertSpyCall(test, 0);
1564+
const call = test.calls[0];
15581565
const options = call.args[0] as Deno.TestDefinition;
15591566
assertEquals(Object.keys(options).sort(), ["fn", "name"]);
15601567
assertEquals(options.name, "example");

test_deps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ export {
66
assertRejects,
77
assertStrictEquals,
88
assertThrows,
9-
} from "https://deno.land/std@0.130.0/testing/asserts.ts";
9+
} from "https://deno.land/std@0.133.0/testing/asserts.ts";
1010

1111
export {
1212
assertSpyCall,
1313
assertSpyCalls,
1414
spy,
1515
stub,
16-
} from "https://deno.land/x/mock@0.15.0/mod.ts";
16+
} from "https://deno.land/std@0.133.0/testing/mock.ts";
1717
export type {
1818
Spy,
1919
SpyCall,
2020
Stub,
21-
} from "https://deno.land/x/mock@0.15.0/mod.ts";
21+
} from "https://deno.land/std@0.133.0/testing/mock.ts";

test_suite.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ export class TestSuiteInternal<T> implements TestSuite<T> {
200200
}
201201
suite.hasOnlyStep = true;
202202
}
203+
204+
const parentSuite = suite.describe.suite;
205+
const parentTestSuite = parentSuite &&
206+
TestSuiteInternal.suites.get(parentSuite.symbol);
207+
if (parentTestSuite) {
208+
TestSuiteInternal.addingOnlyStep(parentTestSuite);
209+
}
203210
}
204211

205212
/** This is used internally to add steps to a test suite. */

0 commit comments

Comments
 (0)