Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/probes/isUnaryExpression.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Import Third-party dependencies
import test from "tape";

// Import Internal Dependencies
import { getSastAnalysis, parseScript } from "../utils/index.js";
import isUnaryExpression from "../../src/probes/isUnaryExpression.js";

test("should detect one UnaryArray", (tape) => {
const str = "!![]";
const ast = parseScript(str);
const { analysis } = getSastAnalysis(str, isUnaryExpression)
.execute(ast.body);

tape.strictEqual(analysis.counter.doubleUnaryArray, 1);

tape.end();
});

test("should not detect any UnaryArray", (tape) => {
const str = "![]";
const ast = parseScript(str);
const { analysis } = getSastAnalysis(str, isUnaryExpression)
.execute(ast.body);

tape.strictEqual(analysis.counter.doubleUnaryArray, 0);

tape.end();
});