Skip to content

Commit 99a75a3

Browse files
committed
break out expectMatchingValues into another file
1 parent b474ab7 commit 99a75a3

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
4+
import { expectEqualPromisesOrValues } from '../expectEqualPromisesOrValues';
5+
6+
describe('expectMatchingValues', () => {
7+
it('throws when given unequal values', () => {
8+
expect(() => expectEqualPromisesOrValues([{}, {}, { test: 'test' }])).throw(
9+
"expected { test: 'test' } to deeply equal {}",
10+
);
11+
});
12+
13+
it('does not throw when given equal values', () => {
14+
const testValue = { test: 'test' };
15+
expect(() =>
16+
expectEqualPromisesOrValues([testValue, testValue, testValue]),
17+
).not.to.throw();
18+
});
19+
});

src/__testUtils__/expectEqualPromisesOrValues.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { assert } from 'chai';
33
import { isPromise } from '../jsutils/isPromise';
44
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
55

6-
import { expectJSON } from './expectJSON';
6+
import { expectMatchingValues } from './expectMatchingValues';
77

88
export function expectEqualPromisesOrValues<T>(
99
items: ReadonlyArray<PromiseOrValue<T>>,
@@ -21,11 +21,3 @@ export function expectEqualPromisesOrValues<T>(
2121

2222
assert(false, 'Received an invalid mixture of promises and values.');
2323
}
24-
25-
function expectMatchingValues<T>(values: ReadonlyArray<T>): T {
26-
const remainingValues = values.slice(1);
27-
for (const value of remainingValues) {
28-
expectJSON(value).toDeepEqual(values[0]);
29-
}
30-
return values[0];
31-
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { expectJSON } from './expectJSON';
2+
3+
export function expectMatchingValues<T>(values: ReadonlyArray<T>): T {
4+
const remainingValues = values.slice(1);
5+
for (const value of remainingValues) {
6+
expectJSON(value).toDeepEqual(values[0]);
7+
}
8+
return values[0];
9+
}

0 commit comments

Comments
 (0)