Best JavaScript code snippet using best
configuration-test.js
Source:configuration-test.js
...144});145describe('configuration', () => {146 describe("with -c set to string 'true'", () => {147 const config = { c: 'true' };148 const normalizedConfig = normalizeConfig(config);149 const { warnings, errors } = validateConfig(config);150 it('gets removed', () => {151 assert.notProperty(normalizedConfig, 'c');152 });153 it('produces one warning', () => {154 assert.lengthOf(warnings, 1);155 });156 it('produces no errors', () => {157 assert.lengthOf(errors, 0);158 });159 });160 describe("with --color set to string 'true'", () => {161 const config = { color: 'true' };162 const normalizedConfig = normalizeConfig(config);163 const { warnings, errors } = validateConfig(config);164 it('gets coerced to color set to boolean true', () => {165 assert.propertyVal(normalizedConfig, 'color', true);166 });167 it('produces no warnings', () => {168 assert.lengthOf(warnings, 0);169 });170 it('produces no errors', () => {171 assert.lengthOf(errors, 0);172 });173 });174 describe("with --color set to string 'false'", () => {175 const config = { color: 'false' };176 const normalizedConfig = normalizeConfig(config);177 const { warnings, errors } = validateConfig(config);178 it('gets coerced to color set to boolean false', () => {179 assert.propertyVal(normalizedConfig, 'color', false);180 });181 it('produces no warnings', () => {182 assert.lengthOf(warnings, 0);183 });184 it('produces no errors', () => {185 assert.lengthOf(errors, 0);186 });187 });188 describe('with --color set to true', () => {189 const config = { color: true };190 const normalizedConfig = normalizeConfig(config);191 const { warnings, errors } = validateConfig(config);192 it('gets coerced to color set to boolean true', () => {193 assert.propertyVal(normalizedConfig, 'color', true);194 });195 it('produces no warnings', () => {196 assert.lengthOf(warnings, 0);197 });198 it('produces no errors', () => {199 assert.lengthOf(errors, 0);200 });201 });202 describe('with --color set to false', () => {203 const config = { color: false };204 const normalizedConfig = normalizeConfig(config);205 const { warnings, errors } = validateConfig(config);206 it('gets coerced to color set to boolean false', () => {207 assert.propertyVal(normalizedConfig, 'color', false);208 });209 it('produces no warnings', () => {210 assert.lengthOf(warnings, 0);211 });212 it('produces no errors', () => {213 assert.lengthOf(errors, 0);214 });215 });216 describe('with --level/-l set to a supported value', () => {217 const config = { l: 'debug', level: 'debug' };218 const normalizedConfig = normalizeConfig(config);219 const { warnings, errors } = validateConfig(config);220 it('gets coerced to loglevel set to the value', () => {221 assert.propertyVal(normalizedConfig, 'loglevel', 'debug');222 assert.notProperty(normalizedConfig, 'l');223 assert.notProperty(normalizedConfig, 'level');224 });225 it('produces one warnings', () => {226 assert.lengthOf(warnings, 1);227 });228 it('produces no errors', () => {229 assert.lengthOf(errors, 0);230 });231 });232 describe('with --level/-l set to a consolidated value', () => {233 const config = { l: 'verbose', level: 'verbose' };234 const normalizedConfig = normalizeConfig(config);235 const { warnings, errors } = validateConfig(config);236 it('gets coerced to loglevel set to a corresponding value', () => {237 assert.propertyVal(normalizedConfig, 'loglevel', 'debug');238 assert.notProperty(normalizedConfig, 'l');239 assert.notProperty(normalizedConfig, 'level');240 });241 it('produces one warning', () => {242 assert.lengthOf(warnings, 1);243 });244 it('produces no errors', () => {245 assert.lengthOf(errors, 0);246 });247 });248 describe('with --level/-l set to a removed value', () => {249 const config = { l: 'complete', level: 'complete' };250 const normalizedConfig = normalizeConfig(config);251 const { warnings, errors } = validateConfig(config);252 it('gets coerced to loglevel set to the default value', () => {253 assert.propertyVal(normalizedConfig, 'loglevel', 'warn');254 assert.notProperty(normalizedConfig, 'l');255 assert.notProperty(normalizedConfig, 'level');256 });257 it('produces one warning', () => {258 assert.lengthOf(warnings, 1);259 });260 it('produces no errors', () => {261 assert.lengthOf(errors, 0);262 });263 });264 describe("with -l set to 'silent'", () => {265 const config = { l: 'silent' };266 const normalizedConfig = normalizeConfig(config);267 const { warnings, errors } = validateConfig(config);268 it('gets coerced to loglevel set to silent', () => {269 assert.propertyVal(normalizedConfig, 'loglevel', 'silent');270 assert.notProperty(normalizedConfig, 'l');271 assert.notProperty(normalizedConfig, 'level');272 });273 it('produces no warnings', () => {274 assert.lengthOf(warnings, 0);275 });276 it('produces no errors', () => {277 assert.lengthOf(errors, 0);278 });279 });280 describe('with --timestamp set', () => {281 const config = { timestamp: true };282 const normalizedConfig = normalizeConfig(config);283 const { warnings, errors } = validateConfig(config);284 it('gets removed', () => {285 assert.notProperty(normalizedConfig, 'timestamp');286 });287 it('produces no warnings', () => {288 assert.lengthOf(warnings, 0);289 });290 it('produces one error', () => {291 assert.lengthOf(errors, 1);292 });293 });294 describe('with -t set', () => {295 const config = { t: true };296 const normalizedConfig = normalizeConfig(config);297 const { warnings, errors } = validateConfig(config);298 it('gets removed', () => {299 assert.notProperty(normalizedConfig, 't');300 });301 it('produces no warnings', () => {302 assert.lengthOf(warnings, 0);303 });304 it('produces one error', () => {305 assert.lengthOf(errors, 1);306 });307 });308 describe('with --silent set', () => {309 const config = { silent: true };310 const normalizedConfig = normalizeConfig(config);311 const { warnings, errors } = validateConfig(config);312 it('gets removed', () => {313 assert.notProperty(normalizedConfig, 'silent');314 });315 it('produces no warnings', () => {316 assert.lengthOf(warnings, 0);317 });318 it('produces one error', () => {319 assert.lengthOf(errors, 1);320 });321 });322 describe('with -q set', () => {323 const config = { q: true };324 const normalizedConfig = normalizeConfig(config);325 const { warnings, errors } = validateConfig(config);326 it('gets removed', () => {327 assert.notProperty(normalizedConfig, 'q');328 });329 it('produces no warnings', () => {330 assert.lengthOf(warnings, 0);331 });332 it('produces one error', () => {333 assert.lengthOf(errors, 1);334 });335 });336 describe('with --sandbox/-b set', () => {337 const config = { sandbox: true };338 const normalizedConfig = normalizeConfig(config);339 const { warnings, errors } = validateConfig(config);340 it('gets removed', () => {341 assert.notProperty(normalizedConfig, 'sandbox');342 });343 it('produces no warnings', () => {344 assert.lengthOf(warnings, 0);345 });346 it('produces one error', () => {347 assert.lengthOf(errors, 1);348 });349 });350 describe('with -b set', () => {351 const config = { b: true };352 const normalizedConfig = normalizeConfig(config);353 const { warnings, errors } = validateConfig(config);354 it('gets removed', () => {355 assert.notProperty(normalizedConfig, 'b');356 });357 it('produces no warnings', () => {358 assert.lengthOf(warnings, 0);359 });360 it('produces one error', () => {361 assert.lengthOf(errors, 1);362 });363 });364 describe('with data set to { filename: apiDescription }', () => {365 const config = { data: { 'filename.api': 'FORMAT: 1A\n# Sample API\n' } };366 const { warnings, errors } = validateConfig(config);...
utils-normalizeConfig-test.js
Source:utils-normalizeConfig-test.js
...25 utils = require('../utils');26 });27 it('throws when an invalid config option is passed in', function() {28 expect(function() {29 utils.normalizeConfig({30 rootDir: '/root/path/foo',31 thisIsAnInvalidConfigKey: 'with a value even!'32 });33 }).toThrow('Unknown config option: thisIsAnInvalidConfigKey');34 });35 describe('rootDir', function() {36 it('throws if the config is missing a rootDir property', function() {37 expect(function() {38 utils.normalizeConfig({});39 }).toThrow('No rootDir config value found!');40 });41 });42 describe('collectCoverageOnlyFrom', function() {43 it('normalizes all paths relative to rootDir', function() {44 var config = utils.normalizeConfig({45 rootDir: '/root/path/foo/',46 collectCoverageOnlyFrom: {47 'bar/baz': true,48 'qux/quux/': true49 }50 }, '/root/path');51 var expected = {};52 expected[expectedPathFooBar] = true;53 expected[expectedPathFooQux] = true;54 expect(config.collectCoverageOnlyFrom).toEqual(expected);55 });56 it('does not change absolute paths', function() {57 var config = utils.normalizeConfig({58 rootDir: '/root/path/foo',59 collectCoverageOnlyFrom: {60 '/an/abs/path': true,61 '/another/abs/path': true62 }63 });64 var expected = {};65 expected[expectedPathAbs] = true;66 expected[expectedPathAbsAnother] = true;67 expect(config.collectCoverageOnlyFrom).toEqual(expected);68 });69 it('substitutes <rootDir> tokens', function() {70 var config = utils.normalizeConfig({71 rootDir: '/root/path/foo',72 collectCoverageOnlyFrom: {73 '<rootDir>/bar/baz': true74 }75 });76 var expected = {};77 expected[expectedPathFooBar] = true;78 expect(config.collectCoverageOnlyFrom).toEqual(expected);79 });80 });81 describe('testPathDirs', function() {82 it('normalizes all paths relative to rootDir', function() {83 var config = utils.normalizeConfig({84 rootDir: '/root/path/foo',85 testPathDirs: [86 'bar/baz',87 'qux/quux/'88 ]89 }, '/root/path');90 expect(config.testPathDirs).toEqual([91 expectedPathFooBar, expectedPathFooQux92 ]);93 });94 it('does not change absolute paths', function() {95 var config = utils.normalizeConfig({96 rootDir: '/root/path/foo',97 testPathDirs: [98 '/an/abs/path',99 '/another/abs/path'100 ]101 });102 expect(config.testPathDirs).toEqual([103 expectedPathAbs, expectedPathAbsAnother104 ]);105 });106 it('substitutes <rootDir> tokens', function() {107 var config = utils.normalizeConfig({108 rootDir: '/root/path/foo',109 testPathDirs: [110 '<rootDir>/bar/baz'111 ]112 });113 expect(config.testPathDirs).toEqual([expectedPathFooBar]);114 });115 });116 describe('scriptPreprocessor', function() {117 it('normalizes the path according to rootDir', function() {118 var config = utils.normalizeConfig({119 rootDir: '/root/path/foo',120 scriptPreprocessor: 'bar/baz'121 }, '/root/path');122 expect(config.scriptPreprocessor).toEqual(expectedPathFooBar);123 });124 it('does not change absolute paths', function() {125 var config = utils.normalizeConfig({126 rootDir: '/root/path/foo',127 scriptPreprocessor: '/an/abs/path'128 });129 expect(config.scriptPreprocessor).toEqual(expectedPathAbs);130 });131 it('substitutes <rootDir> tokens', function() {132 var config = utils.normalizeConfig({133 rootDir: '/root/path/foo',134 scriptPreprocessor: '<rootDir>/bar/baz'135 });136 expect(config.scriptPreprocessor).toEqual(expectedPathFooBar);137 });138 });139 describe('setupEnvScriptFile', function() {140 it('normalizes the path according to rootDir', function() {141 var config = utils.normalizeConfig({142 rootDir: '/root/path/foo',143 setupEnvScriptFile: 'bar/baz'144 }, '/root/path');145 expect(config.setupEnvScriptFile).toEqual(expectedPathFooBar);146 });147 it('does not change absolute paths', function() {148 var config = utils.normalizeConfig({149 rootDir: '/root/path/foo',150 setupEnvScriptFile: '/an/abs/path'151 });152 expect(config.setupEnvScriptFile).toEqual(expectedPathAbs);153 });154 it('substitutes <rootDir> tokens', function() {155 var config = utils.normalizeConfig({156 rootDir: '/root/path/foo',157 setupEnvScriptFile: '<rootDir>/bar/baz'158 });159 expect(config.setupEnvScriptFile).toEqual(expectedPathFooBar);160 });161 });162 describe('setupTestFrameworkScriptFile', function() {163 it('normalizes the path according to rootDir', function() {164 var config = utils.normalizeConfig({165 rootDir: '/root/path/foo',166 setupTestFrameworkScriptFile: 'bar/baz'167 }, '/root/path');168 expect(config.setupTestFrameworkScriptFile).toEqual(expectedPathFooBar);169 });170 it('does not change absolute paths', function() {171 var config = utils.normalizeConfig({172 rootDir: '/root/path/foo',173 setupTestFrameworkScriptFile: '/an/abs/path'174 });175 expect(config.setupTestFrameworkScriptFile).toEqual(expectedPathAbs);176 });177 it('substitutes <rootDir> tokens', function() {178 var config = utils.normalizeConfig({179 rootDir: '/root/path/foo',180 setupTestFrameworkScriptFile: '<rootDir>/bar/baz'181 });182 expect(config.setupTestFrameworkScriptFile).toEqual(expectedPathFooBar);183 });184 });185 describe('testPathIgnorePatterns', function() {186 it('does not normalize paths relative to rootDir', function() {187 // This is a list of patterns, so we can't assume any of them are188 // directories189 var config = utils.normalizeConfig({190 rootDir: '/root/path/foo',191 testPathIgnorePatterns: [192 'bar/baz',193 'qux/quux'194 ]195 }, '/root/path');196 expect(config.testPathIgnorePatterns).toEqual([197 'bar/baz',198 'qux/quux'199 ]);200 });201 it('does not normalize trailing slashes', function() {202 // This is a list of patterns, so we can't assume any of them are203 // directories204 var config = utils.normalizeConfig({205 rootDir: '/root/path/foo',206 testPathIgnorePatterns: [207 'bar/baz',208 'qux/quux/'209 ]210 });211 expect(config.testPathIgnorePatterns).toEqual([212 'bar/baz',213 'qux/quux/'214 ]);215 });216 it('substitutes <rootDir> tokens', function() {217 var config = utils.normalizeConfig({218 rootDir: '/root/path/foo',219 testPathIgnorePatterns: [220 'hasNoToken',221 '<rootDir>/hasAToken'222 ]223 });224 expect(config.testPathIgnorePatterns).toEqual([225 'hasNoToken',226 '/root/path/foo/hasAToken'227 ]);228 });229 });230 describe('modulePathIgnorePatterns', function() {231 it('does not normalize paths relative to rootDir', function() {232 // This is a list of patterns, so we can't assume any of them are233 // directories234 var config = utils.normalizeConfig({235 rootDir: '/root/path/foo',236 modulePathIgnorePatterns: [237 'bar/baz',238 'qux/quux'239 ]240 }, '/root/path');241 expect(config.modulePathIgnorePatterns).toEqual([242 'bar/baz',243 'qux/quux'244 ]);245 });246 it('does not normalize trailing slashes', function() {247 // This is a list of patterns, so we can't assume any of them are248 // directories249 var config = utils.normalizeConfig({250 rootDir: '/root/path/foo',251 modulePathIgnorePatterns: [252 'bar/baz',253 'qux/quux/'254 ]255 });256 expect(config.modulePathIgnorePatterns).toEqual([257 'bar/baz',258 'qux/quux/'259 ]);260 });261 it('substitutes <rootDir> tokens', function() {262 var config = utils.normalizeConfig({263 rootDir: '/root/path/foo',264 modulePathIgnorePatterns: [265 'hasNoToken',266 '<rootDir>/hasAToken'267 ]268 });269 expect(config.modulePathIgnorePatterns).toEqual([270 'hasNoToken',271 '/root/path/foo/hasAToken'272 ]);273 });274 });...
SearchSource-test.js
Source:SearchSource-test.js
...27 });28 describe('isTestFilePath', () => {29 let config;30 beforeEach(done => {31 config = normalizeConfig({32 name,33 rootDir: '.',34 testPathDirs: [],35 });36 Runtime.createHasteContext(config, {maxWorkers}).then(hasteMap => {37 searchSource = new SearchSource(hasteMap, config);38 done();39 });40 });41 it('supports ../ paths and unix separators', () => {42 if (process.platform !== 'win32') {43 const path = '/path/to/__tests__/foo/bar/baz/../../../test.js';44 expect(searchSource.isTestFilePath(path)).toEqual(true);45 }46 });47 it('supports unix separators', () => {48 if (process.platform !== 'win32') {49 const path = '/path/to/__tests__/test.js';50 expect(searchSource.isTestFilePath(path)).toEqual(true);51 }52 });53 it('supports win32 separators', () => {54 if (process.platform === 'win32') {55 const path = '\\path\\to\\__tests__\\test.js';56 expect(searchSource.isTestFilePath(path)).toEqual(true);57 }58 });59 });60 describe('testPathsMatching', () => {61 beforeEach(() => {62 findMatchingTests = config =>63 Runtime.createHasteContext(config, {maxWorkers}).then(hasteMap =>64 new SearchSource(hasteMap, config).findMatchingTests(),65 );66 });67 it('finds tests matching a pattern', () => {68 const config = normalizeConfig({69 name,70 rootDir,71 moduleFileExtensions: ['js', 'jsx', 'txt'],72 testRegex: 'not-really-a-test',73 });74 return findMatchingTests(config).then(data => {75 const relPaths = data.paths.map(absPath => (76 path.relative(rootDir, absPath)77 ));78 expect(relPaths).toEqual([79 path.normalize('__testtests__/not-really-a-test.txt'),80 ]);81 });82 });83 it('finds tests matching a JS pattern', () => {84 const config = normalizeConfig({85 name,86 rootDir,87 moduleFileExtensions: ['js', 'jsx'],88 testRegex: 'test\.jsx?',89 });90 return findMatchingTests(config).then(data => {91 const relPaths = data.paths.map(absPath => (92 path.relative(rootDir, absPath)93 ));94 expect(relPaths.sort()).toEqual([95 path.normalize('__testtests__/test.js'),96 path.normalize('__testtests__/test.jsx'),97 ]);98 });99 });100 it('finds tests with default file extensions', () => {101 const config = normalizeConfig({102 name,103 rootDir,104 testRegex,105 });106 return findMatchingTests(config).then(data => {107 const relPaths = data.paths.map(absPath => (108 path.relative(rootDir, absPath)109 ));110 expect(relPaths).toEqual([111 path.normalize('__testtests__/test.js'),112 ]);113 });114 });115 it('finds tests with similar but custom file extensions', () => {116 const config = normalizeConfig({117 name,118 rootDir,119 testRegex,120 moduleFileExtensions: ['jsx'],121 });122 return findMatchingTests(config).then(data => {123 const relPaths = data.paths.map(absPath => (124 path.relative(rootDir, absPath)125 ));126 expect(relPaths).toEqual([127 path.normalize('__testtests__/test.jsx'),128 ]);129 });130 });131 it('finds tests with totally custom foobar file extensions', () => {132 const config = normalizeConfig({133 name,134 rootDir,135 testRegex,136 moduleFileExtensions: ['foobar'],137 });138 return findMatchingTests(config).then(data => {139 const relPaths = data.paths.map(absPath => (140 path.relative(rootDir, absPath)141 ));142 expect(relPaths).toEqual([143 path.normalize('__testtests__/test.foobar'),144 ]);145 });146 });147 it('finds tests with many kinds of file extensions', () => {148 const config = normalizeConfig({149 name,150 rootDir,151 testRegex,152 moduleFileExtensions: ['js', 'jsx'],153 });154 return findMatchingTests(config).then(data => {155 const relPaths = data.paths.map(absPath => (156 path.relative(rootDir, absPath)157 ));158 expect(relPaths.sort()).toEqual([159 path.normalize('__testtests__/test.js'),160 path.normalize('__testtests__/test.jsx'),161 ]);162 });163 });164 });165 describe('findRelatedTests', () => {166 const rootDir = path.join(167 __dirname,168 '..',169 '..',170 '..',171 'jest-runtime',172 'src',173 '__tests__',174 'test_root',175 );176 const rootPath = path.join(rootDir, 'root.js');177 beforeEach(done => {178 const config = normalizeConfig({179 name: 'SearchSource-findRelatedTests-tests',180 rootDir,181 });182 Runtime.createHasteContext(config, {maxWorkers}).then(hasteMap => {183 searchSource = new SearchSource(hasteMap, config);184 done();185 });186 });187 it('makes sure a file is related to itself', () => {188 const data = searchSource.findRelatedTests(new Set([rootPath]));189 expect(data.paths).toEqual([rootPath]);190 });191 it('finds tests that depend directly on the path', () => {192 const filePath = path.join(rootDir, 'RegularModule.js');...
test_normalize_config.js
Source:test_normalize_config.js
...5describe('unit/normalizeConfig', () => {6 it('returns null for null config', () => {7 const config = null;8 const expected = null;9 const actual = normalizeConfig(config);10 expect(actual).to.deep.equal(expected);11 });12 it('removes raw off', () => {13 const config = { rules: { rule: 'off' } };14 const expected = { rules: {} };15 const actual = normalizeConfig(config);16 expect(actual).to.deep.equal(expected);17 });18 it('removes embedded off', () => {19 const config = { rules: { rule: ['off', 'something', { key: 'value' }] } };20 const expected = { rules: {} };21 const actual = normalizeConfig(config);22 expect(actual).to.deep.equal(expected);23 });24 it('replaces raw 2 with error', () => {25 const config = { rules: { rule: 2 } };26 const expected = { rules: { rule: ['error'] } };27 const actual = normalizeConfig(config);28 expect(actual).to.deep.equal(expected);29 });30 it('replaces raw 1 with warning', () => {31 const config = { rules: { rule: 1 } };32 const expected = { rules: { rule: ['warning'] } };33 const actual = normalizeConfig(config);34 expect(actual).to.deep.equal(expected);35 });36 it('removes raw 0', () => {37 const config = { rules: { rule: 0 } };38 const expected = { rules: {} };39 const actual = normalizeConfig(config);40 expect(actual).to.deep.equal(expected);41 });42 it('replaces embedded 2 with error', () => {43 const config = { rules: { rule: [2, 'something', { key: 'value' }] } };44 const expected = { rules: { rule: ['error', 'something', { key: 'value' }] } };45 const actual = normalizeConfig(config);46 expect(actual).to.deep.equal(expected);47 });48 it('replaces embedded 1 with warning', () => {49 const config = { rules: { rule: [1, 'something', { key: 'value' }] } };50 const expected = { rules: { rule: ['warning', 'something', { key: 'value' }] } };51 const actual = normalizeConfig(config);52 expect(actual).to.deep.equal(expected);53 });54 it('removes embedded 0', () => {55 const config = { rules: { rule: [0, 'something', { key: 'value' }] } };56 const expected = { rules: {} };57 const actual = normalizeConfig(config);58 expect(actual).to.deep.equal(expected);59 });...
normalizeConfig-test.js
Source:normalizeConfig-test.js
1import normalizeConfig from '../src/normalizeConfig';2import { expect } from 'chai';3describe('normalizeConfig', function () {4 it('creates keys based on config input', () => {5 const result = normalizeConfig({6 npmScope: 'walmart',7 name: 'hello',8 reactNativeVersion: '14.0.5',9 apiVersion: '1.1.0',10 apiDescription: 'Test',11 apiAuthor: 'test',12 bridgeVersion: '1.0.0',13 packageName: '',14 targetDependencies: [],15 });16 expect(result).to.deep.equal({17 moduleName: 'hello',18 namespace: 'com.walmart.hello.ern',19 apiVersion: '1.1.0',20 apiDescription: 'Test',21 npmScope: 'walmart',22 apiAuthor: 'test',23 bridgeVersion: '1.0.0',24 reactNativeVersion: '14.0.5',25 apiSchemaPath: 'schema.json',26 artifactId: 'react-native-hello-api',27 targetDependencies: [],28 });29 });30 it('generates a minimal config', () => {31 const result = normalizeConfig({32 name: 'hello',33 bridgeVersion: '1.0.0',34 reactNativeVersion: '14.0.5',35 });36 expect(result).to.include.any.keys('apiVersion');37 });38 it('normalizes a scoped name', () => {39 const result = normalizeConfig({40 name: '@walmart/sample-test-api',41 bridgeVersion: '1.0.0',42 reactNativeVersion: '1.0.0',43 });44 expect(result).to.include({45 npmScope: 'walmart',46 namespace: 'com.walmart.sampletest.ern',47 moduleName: 'sampletest',48 artifactId: 'react-native-sampletest-api',49 });50 expect(result).to.include.any.keys('apiVersion');51 });52 it('normalizes a scoped name with react-native- prefix', () => {53 const result = normalizeConfig({54 name: '@walmart/react-native-sample-api',55 bridgeVersion: '1.0.0',56 reactNativeVersion: '1.0.0',57 });58 expect(result).to.include({59 npmScope: 'walmart',60 namespace: 'com.walmart.sample.ern',61 moduleName: 'sample',62 artifactId: 'react-native-sample-api',63 });64 expect(result).to.include.any.keys('apiVersion');65 });...
normalize-config.js
Source:normalize-config.js
1import normalizeConfig from '../../src/utils/normalize-config';2describe('normalizeConfig', () => {3 it('adapts a single ID to a hashed product gid', () => {4 const id = 12345;5 const config = normalizeConfig({id});6 assert.deepEqual(config, {7 id,8 storefrontId: btoa(`gid://shopify/Product/${id}`),9 });10 });11 it('doesn\'t clobber existing storefront IDs', () => {12 const storefrontId = btoa('gid://shopify/Product/12345');13 const config = normalizeConfig({storefrontId});14 assert.deepEqual(config, {15 storefrontId,16 });17 });18 it('adapts a variantId to a hashed ProductVariant gid', () => {19 const variantId = 12345;20 const config = normalizeConfig({variantId});21 assert.deepEqual(config, {22 variantId,23 storefrontVariantId: btoa(`gid://shopify/ProductVariant/${variantId}`),24 });25 });26 it('doesn\'t clobber existing storefront variant IDs', () => {27 const storefrontVariantId = btoa('gid://shopify/ProductVariant/12345');28 const config = normalizeConfig({storefrontVariantId});29 assert.deepEqual(config, {30 storefrontVariantId,31 });32 });33 it('adapts a list of product IDs to an array of hashed Product gids', () => {34 const id = [12345, 34567];35 const config = normalizeConfig({id});36 assert.deepEqual(config, {37 id,38 storefrontId: [39 btoa(`gid://shopify/Product/${id[0]}`),40 btoa(`gid://shopify/Product/${id[1]}`),41 ],42 });43 });44 it('adapts other types of base ids to gids', () => {45 const id = 12345;46 const config = normalizeConfig({id}, 'Collection');47 assert.deepEqual(config, {48 id,49 storefrontId: btoa(`gid://shopify/Collection/${id}`),50 });51 });...
_config.test.js
Source:_config.test.js
1import config from './../config';2const { normalizeConfig, hasAuth } = config;3describe('#normalizeConfig', () => {4 it('is should add empty queries array to config', () => {5 expect(normalizeConfig([{}])[0]).toMatchObject({ queries: [] });6 });7 it('is should add empty mutations array to config', () => {8 expect(normalizeConfig([{}])[0]).toMatchObject({ mutations: [] });9 });10 it('is should set type to default one if not passed', () => {11 expect(normalizeConfig([{}])[0]).toMatchObject({ type: 'object' });12 });13 it('is should set auth to default one if not passed', () => {14 expect(normalizeConfig([{}])[0]).toMatchObject({ auth: false });15 });16});17describe('#hasAuth', () => {18 it('should return true if any config object has auth', () => {19 expect(hasAuth([{ auth: true }, { auth: true }])).toBeTruthy();20 });21 it('should return false if config is empty', () => {22 expect(hasAuth([])).toBeFalsy();23 });24 it('should return false if no config has auth', () => {25 expect(hasAuth([{ auth: false }])).toBeFalsy();26 });...
normalizeConfig.test.js
Source:normalizeConfig.test.js
1const normalizeConfig = require("../normalizeConfig");2describe("normalizeConfig", () => {3 it("check cliOptions", () => {4 const config = normalizeConfig({ cliOptions: { arg: "test arg" } });5 expect(config).toEqual({ cliOptions: { arg: "test arg" } });6 });7 it("check default cliOptions", () => {8 const config = normalizeConfig({});9 expect(config).toEqual({ cliOptions: {} });10 });...
Using AI Code Generation
1var BestPractice = require('./BestPractice');2var config = {3};4var config1 = {5};6var config2 = {7};8var config3 = {9};10var config4 = {11};12var config5 = {13};14var config6 = {15};16var config7 = {
Using AI Code Generation
1var BestPracticeConfig = require('./BestPracticeConfig.js');2var bestPracticeConfig = new BestPracticeConfig();3var config = bestPracticeConfig.normalizeConfig();4var BestPractice = require('./BestPractice.js');5var bestPractice = new BestPractice();6var bestPracticeResult = bestPractice.getBestPractice(config);7var BestPractice = require('./BestPractice.js');8var bestPractice = new BestPractice();9var bestPracticeResult = bestPractice.getBestPractice(config);10var BestPractice = require('./BestPractice.js');11var bestPractice = new BestPractice();12var bestPracticeResult = bestPractice.getBestPractice(config);13var BestPractice = require('./BestPractice.js');14var bestPractice = new BestPractice();15var bestPracticeResult = bestPractice.getBestPractice(config);16var BestPractice = require('./BestPractice.js');17var bestPractice = new BestPractice();18var bestPracticeResult = bestPractice.getBestPractice(config);19var BestPractice = require('./BestPractice.js');20var bestPractice = new BestPractice();21var bestPracticeResult = bestPractice.getBestPractice(config);22var BestPractice = require('./BestPractice.js');23var bestPractice = new BestPractice();24var bestPracticeResult = bestPractice.getBestPractice(config);25var BestPractice = require('./BestPractice.js');26var bestPractice = new BestPractice();27var bestPracticeResult = bestPractice.getBestPractice(config);28var BestPractice = require('./BestPractice.js');29var bestPractice = new BestPractice();30var bestPracticeResult = bestPractice.getBestPractice(config);31var BestPractice = require('./BestPractice.js');32var bestPractice = new BestPractice();33var bestPracticeResult = bestPractice.getBestPractice(config);34var BestPractice = require('./BestPractice.js');35var bestPractice = new BestPractice();
Using AI Code Generation
1var bestPractice = require('./bestPractice');2var config = {3 "scripts": {4 },5 "dependencies": {6 }7};8console.log(bestPractice.normalizeConfig(config));
Using AI Code Generation
1var BestPractice = require('bestpractice');2var bp = new BestPractice();3var config = {4 'test1': {5 'test2': {6 }7 }8};9var normalizedConfig = bp.normalizeConfig(config);10console.log(normalizedConfig);11{12}13var BestPractice = require('bestpractice');14var bp = new BestPractice();15var config = {16 'test1': {17 'test2': {18 }19 }20};21var normalizedConfig = bp.normalizeConfig(config, true);22console.log(normalizedConfig);23{24 'test1.test2': {25 },26 'test1': {27 'test2': {28 }29 }30}31var BestPractice = require('bestpractice');32var bp = new BestPractice();33var config = {34};35var normalizedConfig = bp.normalizeConfig(config);36console.log(normalizedConfig);37{38}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!