Skip to content

Commit

Permalink
rename noopThrow helper into throwFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Dec 28, 2022
1 parent 1caed03 commit 1fe4d3b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased 1.8.x

### Added
- `noopThrow` and `noopCallbackFunc` prop values for `set-constant` scriptlet
- `throwFunc` and `noopCallbackFunc` prop values for `set-constant` scriptlet

### Changed

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/noop-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const noopObject = () => ({});
* Function throws an error
* @throws
*/
export const noopThrow = () => {
export const throwFunc = () => {
throw new Error();
};

Expand Down
10 changes: 5 additions & 5 deletions src/scriptlets/set-constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
noopFunc,
trueFunc,
falseFunc,
noopThrow,
throwFunc,
noopPromiseReject,
noopPromiseResolve,
getPropertyInChain,
Expand Down Expand Up @@ -58,7 +58,7 @@ import {
* - `noopCallbackFunc` - function returning noopFunc
* - `trueFunc` - function returning true
* - `falseFunc` - function returning false
* - `noopThrow` - function throwing an error
* - `throwFunc` - function throwing an error
* - `noopPromiseResolve` - function returning Promise object that is resolved with an empty response
* - `noopPromiseReject` - function returning Promise.reject()
* - `''` - empty string
Expand Down Expand Up @@ -122,8 +122,8 @@ export function setConstant(source, property, value, stack) {
constantValue = trueFunc;
} else if (value === 'falseFunc') {
constantValue = falseFunc;
} else if (value === 'noopThrow') {
constantValue = noopThrow;
} else if (value === 'throwFunc') {
constantValue = throwFunc;
} else if (value === 'noopPromiseResolve') {
constantValue = noopPromiseResolve;
} else if (value === 'noopPromiseReject') {
Expand Down Expand Up @@ -294,7 +294,7 @@ setConstant.injections = [
noopCallbackFunc,
trueFunc,
falseFunc,
noopThrow,
throwFunc,
noopPromiseReject,
noopPromiseResolve,
getPropertyInChain,
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/noop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
noopPromiseResolve,
noopCallbackFunc,
noopFunc,
noopThrow,
throwFunc,
} from '../../src/helpers';

const { test, module } = QUnit;
Expand Down Expand Up @@ -35,6 +35,6 @@ test('noopCallbackFunc returns noopFunc', async (assert) => {
assert.strictEqual(func(), undefined, 'function returns undefined');
});

test('noopThrow throws an error', async (assert) => {
assert.throws(() => noopThrow(), 'noopThrow throws an error');
test('throwFunc throws an error', async (assert) => {
assert.throws(() => throwFunc(), 'throwFunc throws an error');
});
8 changes: 4 additions & 4 deletions tests/scriptlets/set-constant.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ if (!isSupported) {
clearGlobalProps(noopCallbackFuncProp);

// setting constant to noopCallbackFunc;
const noopThrowProp = 'noopThrow';
runScriptletFromTag(noopThrowProp, 'noopThrow');
assert.throws(() => window[noopThrowProp]()(), 'noopThrowProp throws an error');
clearGlobalProps(noopThrowProp);
const throwFuncProp = 'throwFunc';
runScriptletFromTag(throwFuncProp, 'throwFunc');
assert.throws(() => window[throwFuncProp]()(), 'throwFuncProp throws an error');
clearGlobalProps(throwFuncProp);

// setting constant to trueFunc;
const trueFuncProp = 'trueFuncProp';
Expand Down

0 comments on commit 1fe4d3b

Please sign in to comment.