it('should not have ' + propKey + ' wildcardIndex if it is specific.', () => { let specQ = duplicate(templateSpecQ); const wildcardIndex = SpecQueryModel.build(specQ, schema, DEFAULT_QUERY_CONFIG).wildcardIndex; assert.isNotOk(wildcardIndex.encodingIndicesByProperty.get(nestedProp)); assert.isNotOk(wildcardIndex.encodings[0]); });
it('utils.isObject()', () => { assert.isOk(isObject({})); assert.isOk(isObject({ 'a': 'b' })); assert.isNotOk(isObject([])); assert.isNotOk(isObject([{}])); assert.isNotOk(isObject([{}, {}])); });
it('truthy test', () => { assert.isNotOk(truthy(undefined)) assert.isNotOk(truthy(null)) assert.isOk(truthy(1)) assert.isOk(truthy({})) assert.isNotOk(truthy(false)) })
it('utils.isPercentage()', () => { assert.isOk(isPercentage('100%')); assert.isOk(isPercentage('1%')); assert.isNotOk(isPercentage('131%')); assert.isNotOk(isPercentage({})); assert.isNotOk(isPercentage([])); });
it('utils.isNumeric()', () => { assert.isOk(isNumeric(324)); assert.isOk(isNumeric('324')); assert.isNotOk(isNumeric('131%')); assert.isNotOk(isNumeric({})); assert.isNotOk(isNumeric([])); });
it('complement test', () => { assert.isFunction(complement(() => { })) const isNotArray = complement(_.isArray) assert.isNotOk(isNotArray([])) assert.isOk(isNotArray(1)) const isNotString = complement(_.isString) assert.isNotOk(isNotString('')) assert.isOk(isNotString(1)) })
it('should returns object with empty obfuscated code and source map with empty data if source code is empty', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( '', Object.assign({}, NO_CUSTOM_NODES_PRESET, { sourceMap: true }) ); assert.isNotOk(obfuscationResult.getObfuscatedCode()); assert.deepEqual(JSON.parse(obfuscationResult.getSourceMap()).names, []); assert.deepEqual(JSON.parse(obfuscationResult.getSourceMap()).sources, []); assert.isNotOk(JSON.parse(obfuscationResult.getSourceMap()).mappings); });
test('shell and fragments with shared dependency', async () => { await setupTest({ root: defaultRoot, entrypoint: 'entrypoint-a.html', shell: 'shell.html', fragments: ['entrypoint-b.html', 'entrypoint-c.html'], }); // shell bundles framework const shellDoc = parse5(getFileOrDie('shell.html')); assert.isTrue(hasMarker(shellDoc, 'framework')); assert.isFalse(hasImport(shellDoc, 'framework.html')); // shell bundles commonDep assert.isTrue(hasMarker(shellDoc, 'commonDep')); assert.isFalse(hasImport(shellDoc, 'common-dependency.html')); // entrypoint B doesn't import commonDep const entrypointBDoc = parse5(getFileOrDie('entrypoint-b.html')); assert.isFalse(hasMarker(entrypointBDoc, 'commonDep')); assert.isFalse(hasImport(entrypointBDoc, 'common-dependency.html')); // entrypoint C doesn't import commonDep const entrypointCDoc = parse5(getFileOrDie('entrypoint-c.html')); assert.isFalse(hasMarker(entrypointCDoc, 'commonDep')); assert.isFalse(hasImport(entrypointCDoc, 'common-dependency.html')); // entrypoints don't import shell assert.isFalse(hasImport(entrypointBDoc, 'shell.html')); assert.isFalse(hasImport(entrypointCDoc, 'shell.html')); // No shared-bundle with a shell assert.isNotOk(getFile('shared_bundle_1.html')); });
test('bundler does not output inlined html imports', async () => { await setupTest({root: defaultRoot, entrypoint: 'entrypoint-only.html'}); // We should have an entrypoint-only.html file (bundled). assert.isOk(getFile('entrypoint-only.html')); // We should not have the inlined file in the output. assert.isNotOk(getFile('framework.html')); });
it('should have no mark wildcardIndex if mark is specific.', () => { const specQ: SpecQuery = { mark: Mark.BAR, encodings: [] }; const wildcardIndex = SpecQueryModel.build(specQ, schema, DEFAULT_QUERY_CONFIG).wildcardIndex; assert.isNotOk(wildcardIndex.mark); });