initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

170
node_modules/jest-snapshot/build/State.js generated vendored Normal file
View File

@@ -0,0 +1,170 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class SnapshotState {
constructor(testPath, options) {
this._snapshotPath = options.snapshotPath || (0, _utils.getSnapshotPath)(testPath);
var _getSnapshotData = (0, _utils.getSnapshotData)(this._snapshotPath, options.updateSnapshot);
const data = _getSnapshotData.data,
dirty = _getSnapshotData.dirty;
this._snapshotData = data;
this._dirty = dirty;
this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
this._counters = new Map();
this._index = 0;
this.expand = options.expand || false;
this.added = 0;
this.matched = 0;
this.unmatched = 0;
this._updateSnapshot = options.updateSnapshot;
this.updated = 0;
}
markSnapshotsAsCheckedForTest(testName) {
this._uncheckedKeys.forEach(uncheckedKey => {
if ((0, _utils.keyToTestName)(uncheckedKey) === testName) {
this._uncheckedKeys.delete(uncheckedKey);
}
});
}
_addSnapshot(key, receivedSerialized) {
this._dirty = true;
this._snapshotData[key] = receivedSerialized;
}
save() {
const isEmpty = Object.keys(this._snapshotData).length === 0;
const status = {
deleted: false,
saved: false
};
if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
(0, _utils.saveSnapshotFile)(this._snapshotData, this._snapshotPath);
status.saved = true;
} else if (isEmpty && _fs2.default.existsSync(this._snapshotPath)) {
if (this._updateSnapshot === 'all') {
_fs2.default.unlinkSync(this._snapshotPath);
}
status.deleted = true;
}
return status;
}
getUncheckedCount() {
return this._uncheckedKeys.size || 0;
}
getUncheckedKeys() {
return Array.from(this._uncheckedKeys);
}
removeUncheckedKeys() {
if (this._updateSnapshot === 'all' && this._uncheckedKeys.size) {
this._dirty = true;
this._uncheckedKeys.forEach(key => delete this._snapshotData[key]);
this._uncheckedKeys.clear();
}
}
match(testName, received, key) {
this._counters.set(testName, (this._counters.get(testName) || 0) + 1);
const count = Number(this._counters.get(testName));
if (!key) {
key = (0, _utils.testNameToKey)(testName, count);
}
this._uncheckedKeys.delete(key);
const receivedSerialized = (0, _utils.serialize)(received);
const expected = this._snapshotData[key];
const pass = expected === receivedSerialized;
const hasSnapshot = this._snapshotData[key] !== undefined;
if (pass) {
// Executing a snapshot file as JavaScript and writing the strings back
// when other snapshots have changed loses the proper escaping for some
// characters. Since we check every snapshot in every test, use the newly
// generated formatted string.
// Note that this is only relevant when a snapshot is added and the dirty
// flag is set.
this._snapshotData[key] = receivedSerialized;
}
// These are the conditions on when to write snapshots:
// * There's no snapshot file in a non-CI environment.
// * There is a snapshot file and we decided to update the snapshot.
// * There is a snapshot file, but it doesn't have this snaphsot.
// These are the conditions on when not to write snapshots:
// * The update flag is set to 'none'.
// * There's no snapshot file or a file without this snapshot on a CI environment.
if (hasSnapshot && this._updateSnapshot === 'all' || (!hasSnapshot || !_fs2.default.existsSync(this._snapshotPath)) && (this._updateSnapshot === 'new' || this._updateSnapshot === 'all')) {
if (this._updateSnapshot === 'all') {
if (!pass) {
if (hasSnapshot) {
this.updated++;
} else {
this.added++;
}
this._addSnapshot(key, receivedSerialized);
} else {
this.matched++;
}
} else {
this._addSnapshot(key, receivedSerialized);
this.added++;
}
return {
actual: '',
count,
expected: '',
pass: true
};
} else {
if (!pass) {
this.unmatched++;
return {
actual: (0, _utils.unescape)(receivedSerialized),
count,
expected: expected ? (0, _utils.unescape)(expected) : null,
pass: false
};
} else {
this.matched++;
return {
actual: '',
count,
expected: '',
pass: true
};
}
}
}
}
exports.default = SnapshotState; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

146
node_modules/jest-snapshot/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,146 @@
'use strict';
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _jestDiff = require('jest-diff');
var _jestDiff2 = _interopRequireDefault(_jestDiff);
var _jestMatcherUtils = require('jest-matcher-utils');
var _State = require('./State');
var _State2 = _interopRequireDefault(_State);
var _plugins = require('./plugins');
var _utils = require('./utils');
var utils = _interopRequireWildcard(_utils);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const fileExists = (filePath, hasteFS) => hasteFS.exists(filePath) || _fs2.default.existsSync(filePath);
const cleanup = (hasteFS, update) => {
const pattern = '\\.' + utils.SNAPSHOT_EXTENSION + '$';
const files = hasteFS.matchFiles(pattern);
const filesRemoved = files.filter(snapshotFile => !fileExists(_path2.default.resolve(_path2.default.dirname(snapshotFile), '..', _path2.default.basename(snapshotFile, '.' + utils.SNAPSHOT_EXTENSION)), hasteFS)).map(snapshotFile => {
if (update === 'all') {
_fs2.default.unlinkSync(snapshotFile);
}
}).length;
return {
filesRemoved
};
};
const toMatchSnapshot = function (received, testName) {
this.dontThrow && this.dontThrow();
const currentTestName = this.currentTestName,
isNot = this.isNot,
snapshotState = this.snapshotState;
if (isNot) {
throw new Error('Jest: `.not` cannot be used with `.toMatchSnapshot()`.');
}
if (!snapshotState) {
throw new Error('Jest: snapshot state must be initialized.');
}
const result = snapshotState.match(testName && currentTestName ? `${currentTestName}: ${testName}` : currentTestName || '', received);
const count = result.count,
pass = result.pass;
let actual = result.actual,
expected = result.expected;
let report;
if (pass) {
return { message: () => '', pass: true };
} else if (!expected) {
report = () => `New snapshot was ${(0, _jestMatcherUtils.RECEIVED_COLOR)('not written')}. The update flag ` + `must be explicitly passed to write a new snapshot.\n\n` + `This is likely because this test is run in a continuous integration ` + `(CI) environment in which snapshots are not written by default.\n\n` + `${(0, _jestMatcherUtils.RECEIVED_COLOR)('Received value')} ` + `${actual}`;
} else {
expected = (expected || '').trim();
actual = (actual || '').trim();
const diffMessage = (0, _jestDiff2.default)(expected, actual, {
aAnnotation: 'Snapshot',
bAnnotation: 'Received',
expand: snapshotState.expand
});
report = () => `${(0, _jestMatcherUtils.RECEIVED_COLOR)('Received value')} does not match ` + `${(0, _jestMatcherUtils.EXPECTED_COLOR)('stored snapshot ' + count)}.\n\n` + (diffMessage || (0, _jestMatcherUtils.EXPECTED_COLOR)('- ' + (expected || '')) + '\n' + (0, _jestMatcherUtils.RECEIVED_COLOR)('+ ' + actual));
}
// Passing the the actual and expected objects so that a custom reporter
// could access them, for example in order to display a custom visual diff,
// or create a different error message
return {
actual,
expected,
message: () => (0, _jestMatcherUtils.matcherHint)('.toMatchSnapshot', 'value', '') + '\n\n' + report(),
name: 'toMatchSnapshot',
pass: false,
report
};
};
const toThrowErrorMatchingSnapshot = function (received, testName, fromPromise) {
this.dontThrow && this.dontThrow();
const isNot = this.isNot;
if (isNot) {
throw new Error('Jest: `.not` cannot be used with `.toThrowErrorMatchingSnapshot()`.');
}
let error;
if (fromPromise) {
error = received;
} else {
try {
received();
} catch (e) {
error = e;
}
}
if (error === undefined) {
throw new Error((0, _jestMatcherUtils.matcherHint)('.toThrowErrorMatchingSnapshot', '() => {}', '') + '\n\n' + `Expected the function to throw an error.\n` + `But it didn't throw anything.`);
}
return toMatchSnapshot.call(this, error.message, testName);
};
module.exports = {
EXTENSION: utils.SNAPSHOT_EXTENSION,
SnapshotState: _State2.default,
addSerializer: _plugins.addSerializer,
cleanup,
getSerializers: _plugins.getSerializers,
toMatchSnapshot,
toThrowErrorMatchingSnapshot,
utils
};

29
node_modules/jest-snapshot/build/mock_serializer.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
const serialize = exports.serialize = (val, config, indentation, depth, refs, printer) => {
// Serialize a non-default name, even if config.printFunctionName is false.
const name = val.getMockName();
const nameString = name === 'jest.fn()' ? '' : ' ' + name;
let callsString = '';
if (val.mock.calls.length !== 0) {
const indentationNext = indentation + config.indent;
callsString = ' {' + config.spacingOuter + indentationNext + '"calls": ' + printer(val.mock.calls, config, indentationNext, depth, refs) + (config.min ? '' : ',') + config.spacingOuter + indentation + '}';
}
return '[MockFunction' + nameString + ']' + callsString;
}; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const test = exports.test = val => val && !!val._isMockFunction;
exports.default = { serialize, test };

41
node_modules/jest-snapshot/build/plugins.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSerializers = exports.addSerializer = undefined;
var _prettyFormat = require('pretty-format');
var _prettyFormat2 = _interopRequireDefault(_prettyFormat);
var _mock_serializer = require('./mock_serializer');
var _mock_serializer2 = _interopRequireDefault(_mock_serializer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _prettyFormat$plugins = _prettyFormat2.default.plugins; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const DOMCollection = _prettyFormat$plugins.DOMCollection,
DOMElement = _prettyFormat$plugins.DOMElement,
Immutable = _prettyFormat$plugins.Immutable,
ReactElement = _prettyFormat$plugins.ReactElement,
ReactTestComponent = _prettyFormat$plugins.ReactTestComponent;
let PLUGINS = [ReactTestComponent, ReactElement, DOMElement, DOMCollection, Immutable, _mock_serializer2.default];
// Prepend to list so the last added is the first tested.
const addSerializer = exports.addSerializer = plugin => {
PLUGINS = [plugin].concat(PLUGINS);
};
const getSerializers = exports.getSerializers = () => PLUGINS;

145
node_modules/jest-snapshot/build/utils.js generated vendored Normal file
View File

@@ -0,0 +1,145 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.saveSnapshotFile = exports.ensureDirectoryExists = exports.unescape = exports.serialize = exports.getSnapshotData = exports.getSnapshotPath = exports.keyToTestName = exports.testNameToKey = exports.SNAPSHOT_VERSION_WARNING = exports.SNAPSHOT_GUIDE_LINK = exports.SNAPSHOT_VERSION = exports.SNAPSHOT_EXTENSION = undefined;
var _plugins = require('./plugins');
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _mkdirp = require('mkdirp');
var _mkdirp2 = _interopRequireDefault(_mkdirp);
var _naturalCompare = require('natural-compare');
var _naturalCompare2 = _interopRequireDefault(_naturalCompare);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _prettyFormat = require('pretty-format');
var _prettyFormat2 = _interopRequireDefault(_prettyFormat);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const SNAPSHOT_EXTENSION = exports.SNAPSHOT_EXTENSION = 'snap';
const SNAPSHOT_VERSION = exports.SNAPSHOT_VERSION = '1';
const SNAPSHOT_VERSION_REGEXP = /^\/\/ Jest Snapshot v(.+),/;
const SNAPSHOT_GUIDE_LINK = exports.SNAPSHOT_GUIDE_LINK = 'https://goo.gl/fbAQLP';
const SNAPSHOT_VERSION_WARNING = exports.SNAPSHOT_VERSION_WARNING = _chalk2.default.yellow(`${_chalk2.default.bold('Warning')}: Before you upgrade snapshots, ` + `we recommend that you revert any local changes to tests or other code, ` + `to ensure that you do not store invalid state.`);
const writeSnapshotVersion = () => `// Jest Snapshot v${SNAPSHOT_VERSION}, ${SNAPSHOT_GUIDE_LINK}`;
const validateSnapshotVersion = snapshotContents => {
const versionTest = SNAPSHOT_VERSION_REGEXP.exec(snapshotContents);
const version = versionTest && versionTest[1];
if (!version) {
return new Error(_chalk2.default.red(`${_chalk2.default.bold('Outdated snapshot')}: No snapshot header found. ` + `Jest 19 introduced versioned snapshots to ensure all developers ` + `on a project are using the same version of Jest. ` + `Please update all snapshots during this upgrade of Jest.\n\n`) + SNAPSHOT_VERSION_WARNING);
}
if (version < SNAPSHOT_VERSION) {
return new Error(_chalk2.default.red(`${_chalk2.default.red.bold('Outdated snapshot')}: The version of the snapshot ` + `file associated with this test is outdated. The snapshot file ` + `version ensures that all developers on a project are using ` + `the same version of Jest. ` + `Please update all snapshots during this upgrade of Jest.\n\n`) + `Expected: v${SNAPSHOT_VERSION}\n` + `Received: v${version}\n\n` + SNAPSHOT_VERSION_WARNING);
}
if (version > SNAPSHOT_VERSION) {
return new Error(_chalk2.default.red(`${_chalk2.default.red.bold('Outdated Jest version')}: The version of this ` + `snapshot file indicates that this project is meant to be used ` + `with a newer version of Jest. The snapshot file version ensures ` + `that all developers on a project are using the same version of ` + `Jest. Please update your version of Jest and re-run the tests.\n\n`) + `Expected: v${SNAPSHOT_VERSION}\n` + `Received: v${version}`);
}
return null;
};
const testNameToKey = exports.testNameToKey = (testName, count) => testName + ' ' + count;
const keyToTestName = exports.keyToTestName = key => {
if (!/ \d+$/.test(key)) {
throw new Error('Snapshot keys must end with a number.');
}
return key.replace(/ \d+$/, '');
};
const getSnapshotPath = exports.getSnapshotPath = testPath => _path2.default.join(_path2.default.join(_path2.default.dirname(testPath), '__snapshots__'), _path2.default.basename(testPath) + '.' + SNAPSHOT_EXTENSION);
const getSnapshotData = exports.getSnapshotData = (snapshotPath, update) => {
const data = Object.create(null);
let snapshotContents = '';
let dirty = false;
if (_fs2.default.existsSync(snapshotPath)) {
try {
snapshotContents = _fs2.default.readFileSync(snapshotPath, 'utf8');
// eslint-disable-next-line no-new-func
const populate = new Function('exports', snapshotContents);
// $FlowFixMe
populate(data);
} catch (e) {}
}
const validationResult = validateSnapshotVersion(snapshotContents);
const isInvalid = snapshotContents && validationResult;
if (update === 'none' && isInvalid) {
throw validationResult;
}
if ((update === 'all' || update === 'new') && isInvalid) {
dirty = true;
}
return { data, dirty };
};
// Extra line breaks at the beginning and at the end of the snapshot are useful
// to make the content of the snapshot easier to read
const addExtraLineBreaks = string => string.includes('\n') ? `\n${string}\n` : string;
const serialize = exports.serialize = data => {
return addExtraLineBreaks(normalizeNewlines((0, _prettyFormat2.default)(data, {
escapeRegex: true,
plugins: (0, _plugins.getSerializers)(),
printFunctionName: false
})));
};
// unescape double quotes
const unescape = exports.unescape = data => data.replace(/\\(")/g, '$1');
const printBacktickString = str => {
return '`' + str.replace(/`|\\|\${/g, '\\$&') + '`';
};
const ensureDirectoryExists = exports.ensureDirectoryExists = filePath => {
try {
_mkdirp2.default.sync(_path2.default.join(_path2.default.dirname(filePath)), '777');
} catch (e) {}
};
const normalizeNewlines = string => string.replace(/\r\n|\r/g, '\n');
const saveSnapshotFile = exports.saveSnapshotFile = (snapshotData, snapshotPath) => {
const snapshots = Object.keys(snapshotData).sort(_naturalCompare2.default).map(key => 'exports[' + printBacktickString(key) + '] = ' + printBacktickString(normalizeNewlines(snapshotData[key])) + ';');
ensureDirectoryExists(snapshotPath);
_fs2.default.writeFileSync(snapshotPath, writeSnapshotVersion() + '\n\n' + snapshots.join('\n\n') + '\n');
};