执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
'use strict';
 
Object.defineProperty(exports, '__esModule', {
  value: true
});
exports.printDiffOrStringified = void 0;
 
var _jestDiff = _interopRequireWildcard(require('jest-diff'));
 
var _jestGetType = _interopRequireWildcard(require('jest-get-type'));
 
var _jestMatcherUtils = require('jest-matcher-utils');
 
var _prettyFormat = _interopRequireDefault(require('pretty-format'));
 
var _utils = require('./utils');
 
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {default: obj};
}
 
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)) {
          var desc =
            Object.defineProperty && Object.getOwnPropertyDescriptor
              ? Object.getOwnPropertyDescriptor(obj, key)
              : {};
          if (desc.get || desc.set) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }
    }
    newObj.default = obj;
    return newObj;
  }
}
 
/**
 * Copyright (c) Facebook, Inc. and its affiliates. 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 isLineDiffable = received => {
  const receivedType = (0, _jestGetType.default)(received);
 
  if ((0, _jestGetType.isPrimitive)(received)) {
    return typeof received === 'string' && received.includes('\n');
  }
 
  if (
    receivedType === 'date' ||
    receivedType === 'function' ||
    receivedType === 'regexp'
  ) {
    return false;
  }
 
  if (received instanceof Error) {
    return false;
  }
 
  if (
    receivedType === 'object' &&
    typeof received.asymmetricMatch === 'function'
  ) {
    return false;
  }
 
  return true;
};
 
const printDiffOrStringified = (
  expectedSerializedTrimmed,
  receivedSerializedTrimmed,
  received,
  expectedLabel,
  receivedLabel,
  expand
) => {
  if (typeof received === 'string') {
    if (
      expectedSerializedTrimmed.length >= 2 &&
      expectedSerializedTrimmed.startsWith('"') &&
      expectedSerializedTrimmed.endsWith('"') &&
      receivedSerializedTrimmed ===
        (0, _utils.unescape)((0, _prettyFormat.default)(received))
    ) {
      // The expected snapshot looks like a stringified string.
      // The received serialization is default stringified string.
      // Undo default serialization of expected snapshot:
      // Remove enclosing double quote marks.
      // Remove backslash escape preceding backslash here,
      // because unescape replaced it only preceding double quote mark.
      return (0, _jestMatcherUtils.printDiffOrStringify)(
        expectedSerializedTrimmed.slice(1, -1).replace(/\\\\/g, '\\'),
        received,
        expectedLabel,
        receivedLabel,
        expand
      );
    } // Display substring highlight even when strings have custom serialization.
 
    const result = (0, _jestDiff.getStringDiff)(
      expectedSerializedTrimmed,
      receivedSerializedTrimmed,
      {
        aAnnotation: expectedLabel,
        bAnnotation: receivedLabel,
        expand
      }
    );
 
    if (result !== null) {
      if (result.isMultiline) {
        return result.annotatedDiff;
      } // Because not default stringify, call EXPECTED_COLOR and RECEIVED_COLOR
      // This is reason to call getStringDiff instead of printDiffOrStringify
      // Because there is no closing double quote mark at end of single lines,
      // future improvement is to call replaceSpacesAtEnd if it becomes public.
 
      const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
        expectedLabel,
        receivedLabel
      );
      return (
        printLabel(expectedLabel) +
        (0, _jestMatcherUtils.EXPECTED_COLOR)(result.a) +
        '\n' +
        printLabel(receivedLabel) +
        (0, _jestMatcherUtils.RECEIVED_COLOR)(result.b)
      );
    }
  }
 
  if (
    (expectedSerializedTrimmed.includes('\n') ||
      receivedSerializedTrimmed.includes('\n')) &&
    isLineDiffable(received)
  ) {
    return (0, _jestDiff.default)(
      expectedSerializedTrimmed,
      receivedSerializedTrimmed,
      {
        aAnnotation: expectedLabel,
        bAnnotation: receivedLabel,
        expand
      }
    );
  }
 
  const printLabel = (0, _jestMatcherUtils.getLabelPrinter)(
    expectedLabel,
    receivedLabel
  );
  return (
    printLabel(expectedLabel) +
    (0, _jestMatcherUtils.EXPECTED_COLOR)(expectedSerializedTrimmed) +
    '\n' +
    printLabel(receivedLabel) +
    (0, _jestMatcherUtils.RECEIVED_COLOR)(receivedSerializedTrimmed)
  );
};
 
exports.printDiffOrStringified = printDiffOrStringified;