mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
`assert.equal` is a non-strict check - it uses `==`. In our tests we should either use: * `assert.strictEqual` which uses `===` * `assert.deepEqual` which does a comparison on objects. Change-Id: I872f9be140dc4c60b199fce94f95d0c12ee2bbc0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2160929 Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Auto-Submit: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
'use strict';
|
|
|
|
const rule = require('../lib/avoid_assert_equal.js');
|
|
const ruleTester = new (require('eslint').RuleTester)({
|
|
parserOptions: {ecmaVersion: 9, sourceType: 'module'},
|
|
});
|
|
|
|
ruleTester.run('avoid_assert_equal', rule, {
|
|
valid: [
|
|
{
|
|
code: `import {assert} from 'chai';
|
|
|
|
it('normal test', async () => {
|
|
assert.strictEqual(2, 2);
|
|
});
|
|
`,
|
|
filename: 'test/e2e/folder/file.ts',
|
|
},
|
|
{
|
|
code: `import {assert} from 'chai';
|
|
|
|
it('normal test', async () => {
|
|
assert.deepEqual([], [])
|
|
});
|
|
`,
|
|
filename: 'test/e2e/folder/file.ts',
|
|
},
|
|
],
|
|
|
|
invalid: [
|
|
{
|
|
code: `import {assert} from 'chai';
|
|
|
|
it('normal test', async () => {
|
|
assert.equal(2, 2)
|
|
});
|
|
`,
|
|
filename: 'test/e2e/folder/file.ts',
|
|
errors: [{message: 'assert.equal is non-strict. Use assert.strictEqual or assert.deepEqual to compare objects'}],
|
|
},
|
|
]
|
|
});
|