11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif ((!common.hasCrypto) || (!common.hasIntl)) { 51cb0ef41Sopenharmony_ci common.skip('ESLint tests require crypto and Intl'); 61cb0ef41Sopenharmony_ci} 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cicommon.skipIfEslintMissing(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst RuleTester = require('../../tools/node_modules/eslint').RuleTester; 111cb0ef41Sopenharmony_ciconst rule = require('../../tools/eslint-rules/required-modules'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinew RuleTester().run('required-modules', rule, { 141cb0ef41Sopenharmony_ci valid: [ 151cb0ef41Sopenharmony_ci { 161cb0ef41Sopenharmony_ci code: 'require("common")', 171cb0ef41Sopenharmony_ci options: [{ common: 'common' }] 181cb0ef41Sopenharmony_ci }, 191cb0ef41Sopenharmony_ci { 201cb0ef41Sopenharmony_ci code: 'foo', 211cb0ef41Sopenharmony_ci options: [] 221cb0ef41Sopenharmony_ci }, 231cb0ef41Sopenharmony_ci { 241cb0ef41Sopenharmony_ci code: 'require("common")', 251cb0ef41Sopenharmony_ci options: [{ common: 'common(/index\\.(m)?js)?$' }] 261cb0ef41Sopenharmony_ci }, 271cb0ef41Sopenharmony_ci { 281cb0ef41Sopenharmony_ci code: 'require("common/index.js")', 291cb0ef41Sopenharmony_ci options: [{ common: 'common(/index\\.(m)?js)?$' }] 301cb0ef41Sopenharmony_ci }, 311cb0ef41Sopenharmony_ci ], 321cb0ef41Sopenharmony_ci invalid: [ 331cb0ef41Sopenharmony_ci { 341cb0ef41Sopenharmony_ci code: 'foo', 351cb0ef41Sopenharmony_ci options: [{ common: 'common' }], 361cb0ef41Sopenharmony_ci errors: [{ message: 'Mandatory module "common" must be loaded.' }] 371cb0ef41Sopenharmony_ci }, 381cb0ef41Sopenharmony_ci { 391cb0ef41Sopenharmony_ci code: 'require("common/fixtures.js")', 401cb0ef41Sopenharmony_ci options: [{ common: 'common(/index\\.(m)?js)?$' }], 411cb0ef41Sopenharmony_ci errors: [{ 421cb0ef41Sopenharmony_ci message: 431cb0ef41Sopenharmony_ci 'Mandatory module "common" must be loaded.' 441cb0ef41Sopenharmony_ci }] 451cb0ef41Sopenharmony_ci }, 461cb0ef41Sopenharmony_ci { 471cb0ef41Sopenharmony_ci code: 'require("somethingElse")', 481cb0ef41Sopenharmony_ci options: [{ common: 'common' }], 491cb0ef41Sopenharmony_ci errors: [{ message: 'Mandatory module "common" must be loaded.' }] 501cb0ef41Sopenharmony_ci }, 511cb0ef41Sopenharmony_ci ] 521cb0ef41Sopenharmony_ci}); 53