Skip to content

Commit 3e79b7b

Browse files
committed
Remove expect.assertions
1 parent 7e237a5 commit 3e79b7b

File tree

7 files changed

+0
-59
lines changed

7 files changed

+0
-59
lines changed

node_package/tests/Authenticity.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,21 @@ document.head.appendChild(meta);
99

1010
describe('authenticityToken', () => {
1111
it('exists in ReactOnRails API', () => {
12-
expect.assertions(1);
1312
expect(typeof ReactOnRails.authenticityToken).toBe('function');
1413
});
1514

1615
it('can read Rails CSRF token from <meta>', () => {
17-
expect.assertions(1);
1816
const realToken = ReactOnRails.authenticityToken();
1917
expect(realToken).toEqual(testToken);
2018
});
2119
});
2220

2321
describe('authenticityHeaders', () => {
2422
it('exists in ReactOnRails API', () => {
25-
expect.assertions(1);
2623
expect(typeof ReactOnRails.authenticityHeaders).toBe('function');
2724
});
2825

2926
it('returns valid header with CSRF token', () => {
30-
expect.assertions(1);
3127
const realHeader = ReactOnRails.authenticityHeaders();
3228
expect(realHeader).toEqual({ 'X-CSRF-Token': testToken, 'X-Requested-With': 'XMLHttpRequest' });
3329
});

node_package/tests/ComponentRegistry.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ describe('ComponentRegistry', () => {
3737
});
3838

3939
it('registers and retrieves React function components', () => {
40-
expect.assertions(1);
4140
const C1 = () => <div>HELLO</div>;
4241
ComponentRegistry.register({ C1 });
4342
const actual = ComponentRegistry.get('C1');
@@ -46,7 +45,6 @@ describe('ComponentRegistry', () => {
4645
});
4746

4847
it('registers and retrieves Render-Function components where property renderFunction is set and zero params', () => {
49-
expect.assertions(1);
5048
const C1 = () => <div>HELLO</div>;
5149
C1.renderFunction = true;
5250
ComponentRegistry.register({ C1 });
@@ -56,7 +54,6 @@ describe('ComponentRegistry', () => {
5654
});
5755

5856
it('registers and retrieves ES5 class components', () => {
59-
expect.assertions(1);
6057
const C2 = createReactClass({
6158
render() {
6259
return <div> WORLD </div>;
@@ -69,7 +66,6 @@ describe('ComponentRegistry', () => {
6966
});
7067

7168
it('registers and retrieves ES6 class components', () => {
72-
expect.assertions(1);
7369
class C3 extends React.Component {
7470
render() {
7571
return <div>Wow!</div>;
@@ -82,7 +78,6 @@ describe('ComponentRegistry', () => {
8278
});
8379

8480
it('registers and retrieves renderers if 3 params', () => {
85-
expect.assertions(1);
8681
const C4 = (a1, a2, a3) => null;
8782
ComponentRegistry.register({ C4 });
8883
const actual = ComponentRegistry.get('C4');
@@ -95,7 +90,6 @@ describe('ComponentRegistry', () => {
9590
* Thus, tests are cumulative.
9691
*/
9792
it('registers and retrieves multiple components', () => {
98-
expect.assertions(4);
9993
// Plain react stateless functional components
10094
const C5 = () => <div>WHY</div>;
10195
const C6 = () => <div>NOW</div>;
@@ -127,7 +121,6 @@ describe('ComponentRegistry', () => {
127121
});
128122

129123
it('only detects a renderer function if it has three arguments', () => {
130-
expect.assertions(2);
131124
const C7 = (a1, a2) => null;
132125
const C8 = (a1) => null;
133126
ComponentRegistry.register({ C7 });
@@ -148,20 +141,17 @@ describe('ComponentRegistry', () => {
148141
});
149142

150143
it('throws error for retrieving unregistered component', () => {
151-
expect.assertions(1);
152144
expect(() => ComponentRegistry.get('foobar')).toThrow(
153145
/Could not find component registered with name foobar/,
154146
);
155147
});
156148

157149
it('throws error for setting null component', () => {
158-
expect.assertions(1);
159150
const C9 = null;
160151
expect(() => ComponentRegistry.register({ C9 })).toThrow(/Called register with null component named C9/);
161152
});
162153

163154
it('retrieves component asynchronously when registered later', async () => {
164-
expect.assertions(1);
165155
const C1 = () => <div>HELLO</div>;
166156
const componentPromise = ComponentRegistry.getOrWaitForComponent('C1');
167157
ComponentRegistry.register({ C1 });
@@ -175,7 +165,6 @@ describe('ComponentRegistry', () => {
175165
});
176166

177167
it('handles timeout for unregistered components', async () => {
178-
expect.assertions(1);
179168
let error;
180169
try {
181170
await ComponentRegistry.getOrWaitForComponent('NonExistent');

node_package/tests/ReactOnRails.test.jsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import ReactOnRails from '../src/ReactOnRails.client.ts';
88

99
describe('ReactOnRails', () => {
1010
it('render returns a virtual DOM element for component', () => {
11-
expect.assertions(1);
1211
const R1 = createReactClass({
1312
render() {
1413
return <div> WORLD </div>;
@@ -29,37 +28,31 @@ describe('ReactOnRails', () => {
2928

3029
it('accepts traceTurbolinks as an option true', () => {
3130
ReactOnRails.resetOptions();
32-
expect.assertions(1);
3331
ReactOnRails.setOptions({ traceTurbolinks: true });
3432
const actual = ReactOnRails.option('traceTurbolinks');
3533
expect(actual).toBe(true);
3634
});
3735

3836
it('accepts traceTurbolinks as an option false', () => {
3937
ReactOnRails.resetOptions();
40-
expect.assertions(1);
4138
ReactOnRails.setOptions({ traceTurbolinks: false });
4239
const actual = ReactOnRails.option('traceTurbolinks');
4340
expect(actual).toBe(false);
4441
});
4542

4643
it('not specified has traceTurbolinks as false', () => {
4744
ReactOnRails.resetOptions();
48-
expect.assertions(1);
4945
ReactOnRails.setOptions({});
5046
const actual = ReactOnRails.option('traceTurbolinks');
5147
expect(actual).toBe(false);
5248
});
5349

5450
it('setOptions method throws error for invalid options', () => {
5551
ReactOnRails.resetOptions();
56-
expect.assertions(1);
5752
expect(() => ReactOnRails.setOptions({ foobar: true })).toThrow(/Invalid option/);
5853
});
5954

6055
it('registerStore throws if passed a falsey object (null, undefined, etc)', () => {
61-
expect.assertions(3);
62-
6356
expect(() => ReactOnRails.registerStore(null)).toThrow(/null or undefined/);
6457

6558
expect(() => ReactOnRails.registerStore(undefined)).toThrow(/null or undefined/);
@@ -68,7 +61,6 @@ describe('ReactOnRails', () => {
6861
});
6962

7063
it('register store and getStoreGenerator allow registration', () => {
71-
expect.assertions(2);
7264
function reducer() {
7365
return {};
7466
}
@@ -86,7 +78,6 @@ describe('ReactOnRails', () => {
8678
});
8779

8880
it('setStore and getStore', () => {
89-
expect.assertions(2);
9081
function reducer() {
9182
return {};
9283
}
@@ -108,7 +99,6 @@ describe('ReactOnRails', () => {
10899
});
109100

110101
it('clearHydratedStores', () => {
111-
expect.assertions(2);
112102
function reducer() {
113103
return {};
114104
}

node_package/tests/StoreRegistry.test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe('StoreRegistry', () => {
2020
});
2121

2222
it('StoreRegistry throws error for registering null or undefined store', () => {
23-
expect.assertions(2);
2423
expect(() => StoreRegistry.register({ storeGenerator: null })).toThrow(
2524
/Called ReactOnRails.registerStoreGenerators with a null or undefined as a value/,
2625
);
@@ -30,14 +29,12 @@ describe('StoreRegistry', () => {
3029
});
3130

3231
it('StoreRegistry throws error for retrieving unregistered store', () => {
33-
expect.assertions(1);
3432
expect(() => StoreRegistry.getStore('foobar')).toThrow(
3533
/There are no stores hydrated and you are requesting the store/,
3634
);
3735
});
3836

3937
it('StoreRegistry registers and retrieves Render-Function stores', () => {
40-
expect.assertions(2);
4138
StoreRegistry.register({ storeGenerator, storeGenerator2 });
4239
const actual = StoreRegistry.getStoreGenerator('storeGenerator');
4340
const expected = storeGenerator;
@@ -48,22 +45,19 @@ describe('StoreRegistry', () => {
4845
});
4946

5047
it('StoreRegistry throws error for retrieving unregistered store generator', () => {
51-
expect.assertions(1);
5248
expect(() => StoreRegistry.getStoreGenerator('foobar')).toThrow(
5349
/Could not find store generator registered with name foobar\. Registered store generator names include/,
5450
);
5551
});
5652

5753
it('StoreRegistry returns undefined for retrieving unregistered store, passing throwIfMissing = false', () => {
58-
expect.assertions(1);
5954
StoreRegistry.setStore('foobarX', {});
6055
const actual = StoreRegistry.getStore('foobar', false);
6156
const expected = undefined;
6257
expect(actual).toEqual(expected);
6358
});
6459

6560
it('StoreRegistry getStore, setStore', () => {
66-
expect.assertions(1);
6761
const store = storeGenerator({});
6862
StoreRegistry.setStore('storeGenerator', store);
6963
const actual = StoreRegistry.getStore('storeGenerator');
@@ -72,14 +66,12 @@ describe('StoreRegistry', () => {
7266
});
7367

7468
it('StoreRegistry throws error for retrieving unregistered hydrated store', () => {
75-
expect.assertions(1);
7669
expect(() => StoreRegistry.getStore('foobar')).toThrow(
7770
/Could not find hydrated store registered with name foobar\. Registered hydrated store names include/,
7871
);
7972
});
8073

8174
it('StoreRegistry clearHydratedStores', () => {
82-
expect.assertions(2);
8375
StoreRegistry.clearHydratedStores();
8476

8577
const result = storeGenerator({});

node_package/tests/buildConsoleReplay.test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,23 @@ import buildConsoleReplay, { consoleReplay } from '../src/buildConsoleReplay.ts'
22

33
describe('consoleReplay', () => {
44
it('does not throw an exception if no console.history object', () => {
5-
expect.assertions(1);
65
expect(() => consoleReplay()).not.toThrow(/Error/);
76
});
87

98
it('returns empty string if no console.history object', () => {
10-
expect.assertions(1);
119
const actual = consoleReplay();
1210
const expected = '';
1311
expect(actual).toEqual(expected);
1412
});
1513

1614
it('returns empty string if console.history is empty', () => {
17-
expect.assertions(1);
1815
console.history = [];
1916
const actual = consoleReplay();
2017
const expected = '';
2118
expect(actual).toEqual(expected);
2219
});
2320

2421
it('replays multiple history messages', () => {
25-
expect.assertions(1);
2622
console.history = [
2723
{ arguments: ['a', 'b'], level: 'log' },
2824
{ arguments: ['c', 'd'], level: 'warn' },
@@ -33,7 +29,6 @@ describe('consoleReplay', () => {
3329
});
3430

3531
it('replays converts console param objects to JSON', () => {
36-
expect.assertions(1);
3732
console.history = [
3833
{ arguments: ['some message', { a: 1, b: 2 }], level: 'log' },
3934
{ arguments: ['other message', { c: 3, d: 4 }], level: 'warn' },
@@ -46,7 +41,6 @@ console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);`;
4641
});
4742

4843
it('replays converts script tag inside of object string to be safe', () => {
49-
expect.assertions(1);
5044
console.history = [
5145
{
5246
arguments: [
@@ -67,7 +61,6 @@ console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);`;
6761
});
6862

6963
it('buildConsoleReplay wraps console replay in a script tag', () => {
70-
expect.assertions(1);
7164
console.history = [
7265
{ arguments: ['some message', { a: 1, b: 2 }], level: 'log' },
7366
{ arguments: ['other message', { c: 3, d: 4 }], level: 'warn' },

node_package/tests/renderFunction.test.jsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import isRenderFunction from '../src/isRenderFunction.ts';
99

1010
describe('isRenderFunction', () => {
1111
it('returns false for a ES5 React Component', () => {
12-
expect.assertions(1);
13-
1412
const es5Component = createReactClass({
1513
render() {
1614
return <div>ES5 React Component</div>;
@@ -21,8 +19,6 @@ describe('isRenderFunction', () => {
2119
});
2220

2321
it('returns false for a ES6 React class', () => {
24-
expect.assertions(1);
25-
2622
class ES6Component extends React.Component {
2723
render() {
2824
return <div>ES6 Component</div>;
@@ -33,8 +29,6 @@ describe('isRenderFunction', () => {
3329
});
3430

3531
it('returns false for a ES6 React subclass', () => {
36-
expect.assertions(1);
37-
3832
class ES6Component extends React.Component {
3933
render() {
4034
return <div>ES6 Component</div>;
@@ -51,33 +45,25 @@ describe('isRenderFunction', () => {
5145
});
5246

5347
it('returns false for a stateless functional component with zero params', () => {
54-
expect.assertions(1);
55-
5648
const pureComponent = () => <h1>Hello</h1>;
5749

5850
expect(isRenderFunction(pureComponent)).toBe(false);
5951
});
6052

6153
it('returns false for a stateless functional component with one param', () => {
62-
expect.assertions(1);
63-
6454
const pureComponent = (props) => <h1>{props.title}</h1>;
6555

6656
expect(isRenderFunction(pureComponent)).toBe(false);
6757
});
6858

6959
it('returns true for a Render-Function (containing two params)', () => {
70-
expect.assertions(1);
71-
7260
const foobarComponent = () => <div>Component for Render-Function</div>;
7361
const foobarrenderFunction = (_props, _railsContext) => foobarComponent;
7462

7563
expect(isRenderFunction(foobarrenderFunction)).toBe(true);
7664
});
7765

7866
it('returns false for simple object', () => {
79-
expect.assertions(1);
80-
8167
const foobarComponent = {
8268
hello() {
8369
return 'world';

node_package/tests/scriptSanitizedVal.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,34 @@ import scriptSanitizedVal from '../src/scriptSanitizedVal.ts';
22

33
describe('scriptSanitizedVal', () => {
44
it('returns no </script if spaces, uppercase 1', () => {
5-
expect.assertions(1);
65
const input = '[SERVER] This is a script:"</div>"</script> <script>alert(\'WTF\')</ SCRIPT >';
76
const actual = scriptSanitizedVal(input);
87
const expected = '[SERVER] This is a script:"</div>"(/script> <script>alert(\'WTF\')(/script >';
98
expect(actual).toEqual(expected);
109
});
1110

1211
it('returns no </script> 2', () => {
13-
expect.assertions(1);
1412
const input = 'Script2:"</div>"</script xx> <script>alert(\'WTF2\')</script xx>';
1513
const actual = scriptSanitizedVal(input);
1614
const expected = 'Script2:"</div>"(/script xx> <script>alert(\'WTF2\')(/script xx>';
1715
expect(actual).toEqual(expected);
1816
});
1917

2018
it('returns no </script> 3', () => {
21-
expect.assertions(1);
2219
const input = 'Script3:"</div>"</ SCRIPT xx> <script>alert(\'WTF3\')</script xx>';
2320
const actual = scriptSanitizedVal(input);
2421
const expected = 'Script3:"</div>"(/script xx> <script>alert(\'WTF3\')(/script xx>';
2522
expect(actual).toEqual(expected);
2623
});
2724

2825
it('returns no </script> 4', () => {
29-
expect.assertions(1);
3026
const input = 'Script4"</div>"</script <script>alert(\'WTF4\')</script>';
3127
const actual = scriptSanitizedVal(input);
3228
const expected = 'Script4"</div>"(/script <script>alert(\'WTF4\')(/script>';
3329
expect(actual).toEqual(expected);
3430
});
3531

3632
it('returns no </script> 5', () => {
37-
expect.assertions(1);
3833
const input = 'Script5:"</div>"</ script> <script>alert(\'WTF5\')</script>';
3934
const actual = scriptSanitizedVal(input);
4035
const expected = 'Script5:"</div>"(/script> <script>alert(\'WTF5\')(/script>';

0 commit comments

Comments
 (0)