@fluid-experimental/property-common 0.49.0 → 0.50.0-41540

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/constants.d.ts +4 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +4 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/packageVersion.d.ts +1 -1
  6. package/dist/packageVersion.d.ts.map +1 -1
  7. package/dist/packageVersion.js +1 -1
  8. package/dist/packageVersion.js.map +1 -1
  9. package/lib/chronometer.d.ts +55 -0
  10. package/lib/chronometer.d.ts.map +1 -0
  11. package/lib/chronometer.js +185 -0
  12. package/lib/chronometer.js.map +1 -0
  13. package/lib/consoleUtils.d.ts +16 -0
  14. package/lib/consoleUtils.d.ts.map +1 -0
  15. package/lib/consoleUtils.js +20 -0
  16. package/lib/consoleUtils.js.map +1 -0
  17. package/lib/constants.d.ts +1219 -0
  18. package/lib/constants.d.ts.map +1 -0
  19. package/lib/constants.js +1274 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/datastructures/collection.d.ts +203 -0
  22. package/lib/datastructures/collection.d.ts.map +1 -0
  23. package/lib/datastructures/collection.js +377 -0
  24. package/lib/datastructures/collection.js.map +1 -0
  25. package/lib/datastructures/dataArray.d.ts +275 -0
  26. package/lib/datastructures/dataArray.d.ts.map +1 -0
  27. package/lib/datastructures/dataArray.js +497 -0
  28. package/lib/datastructures/dataArray.js.map +1 -0
  29. package/lib/datastructures/index.d.ts +9 -0
  30. package/lib/datastructures/index.d.ts.map +1 -0
  31. package/lib/datastructures/index.js +9 -0
  32. package/lib/datastructures/index.js.map +1 -0
  33. package/lib/datastructures/integer64.d.ts +47 -0
  34. package/lib/datastructures/integer64.d.ts.map +1 -0
  35. package/lib/datastructures/integer64.js +140 -0
  36. package/lib/datastructures/integer64.js.map +1 -0
  37. package/lib/datastructures/sortedCollection.d.ts +77 -0
  38. package/lib/datastructures/sortedCollection.d.ts.map +1 -0
  39. package/lib/datastructures/sortedCollection.js +140 -0
  40. package/lib/datastructures/sortedCollection.js.map +1 -0
  41. package/lib/deferredPromise.d.ts +28 -0
  42. package/lib/deferredPromise.d.ts.map +1 -0
  43. package/lib/deferredPromise.js +43 -0
  44. package/lib/deferredPromise.js.map +1 -0
  45. package/lib/deterministicRandomGenerator.d.ts +39 -0
  46. package/lib/deterministicRandomGenerator.d.ts.map +1 -0
  47. package/lib/deterministicRandomGenerator.js +83 -0
  48. package/lib/deterministicRandomGenerator.js.map +1 -0
  49. package/lib/error_objects/flaggedError.d.ts +29 -0
  50. package/lib/error_objects/flaggedError.d.ts.map +1 -0
  51. package/lib/error_objects/flaggedError.js +45 -0
  52. package/lib/error_objects/flaggedError.js.map +1 -0
  53. package/lib/error_objects/httpError.d.ts +31 -0
  54. package/lib/error_objects/httpError.d.ts.map +1 -0
  55. package/lib/error_objects/httpError.js +58 -0
  56. package/lib/error_objects/httpError.js.map +1 -0
  57. package/lib/error_objects/httpErrorNoStack.d.ts +25 -0
  58. package/lib/error_objects/httpErrorNoStack.d.ts.map +1 -0
  59. package/lib/error_objects/httpErrorNoStack.js +29 -0
  60. package/lib/error_objects/httpErrorNoStack.js.map +1 -0
  61. package/lib/error_objects/index.d.ts +9 -0
  62. package/lib/error_objects/index.d.ts.map +1 -0
  63. package/lib/error_objects/index.js +9 -0
  64. package/lib/error_objects/index.js.map +1 -0
  65. package/lib/error_objects/operationError.d.ts +32 -0
  66. package/lib/error_objects/operationError.d.ts.map +1 -0
  67. package/lib/error_objects/operationError.js +73 -0
  68. package/lib/error_objects/operationError.js.map +1 -0
  69. package/lib/guidUtils.d.ts +16 -0
  70. package/lib/guidUtils.d.ts.map +1 -0
  71. package/lib/guidUtils.js +297 -0
  72. package/lib/guidUtils.js.map +1 -0
  73. package/lib/hashCalculator.d.ts +6 -0
  74. package/lib/hashCalculator.d.ts.map +1 -0
  75. package/lib/hashCalculator.js +14 -0
  76. package/lib/hashCalculator.js.map +1 -0
  77. package/lib/index.d.ts +16 -0
  78. package/lib/index.d.ts.map +1 -0
  79. package/lib/index.js +16 -0
  80. package/lib/index.js.map +1 -0
  81. package/lib/joinPaths.d.ts +19 -0
  82. package/lib/joinPaths.d.ts.map +1 -0
  83. package/lib/joinPaths.js +28 -0
  84. package/lib/joinPaths.js.map +1 -0
  85. package/lib/packageVersion.d.ts +9 -0
  86. package/lib/packageVersion.d.ts.map +1 -0
  87. package/lib/packageVersion.js +9 -0
  88. package/lib/packageVersion.js.map +1 -0
  89. package/package.json +22 -2
  90. package/platform-dependent/package.json +1 -1
  91. package/src/constants.ts +5 -0
  92. package/src/packageVersion.ts +1 -1
  93. package/dist/test/chronometer.spec.js +0 -90
  94. package/dist/test/chronometer.spec.js.map +0 -1
  95. package/dist/test/datastructures/collection.spec.js +0 -401
  96. package/dist/test/datastructures/collection.spec.js.map +0 -1
  97. package/dist/test/datastructures/dataArray.spec.js +0 -79
  98. package/dist/test/datastructures/dataArray.spec.js.map +0 -1
  99. package/dist/test/datastructures/sortedCollection.spec.js +0 -106
  100. package/dist/test/datastructures/sortedCollection.spec.js.map +0 -1
  101. package/dist/test/deterministicRandomGenerator.spec.js +0 -18
  102. package/dist/test/deterministicRandomGenerator.spec.js.map +0 -1
  103. package/dist/test/error_objects/flaggedError.spec.js +0 -23
  104. package/dist/test/error_objects/flaggedError.spec.js.map +0 -1
  105. package/dist/test/error_objects/httpError.spec.js +0 -61
  106. package/dist/test/error_objects/httpError.spec.js.map +0 -1
  107. package/dist/test/error_objects/httpErrorNoStack.spec.js +0 -55
  108. package/dist/test/error_objects/httpErrorNoStack.spec.js.map +0 -1
  109. package/dist/test/error_objects/operationError.spec.js +0 -132
  110. package/dist/test/error_objects/operationError.spec.js.map +0 -1
  111. package/dist/test/guidUtils.spec.js +0 -184
  112. package/dist/test/guidUtils.spec.js.map +0 -1
  113. package/dist/test/strings/joinPaths.spec.js +0 -18
  114. package/dist/test/strings/joinPaths.spec.js.map +0 -1
  115. package/dist/test/tsconfig.tsbuildinfo +0 -2278
  116. package/nyc/mocha-junit-report.xml +0 -175
  117. package/src/test/chronometer.spec.ts +0 -99
  118. package/src/test/datastructures/collection.spec.ts +0 -567
  119. package/src/test/datastructures/dataArray.spec.ts +0 -81
  120. package/src/test/datastructures/sortedCollection.spec.ts +0 -128
  121. package/src/test/deterministicRandomGenerator.spec.ts +0 -18
  122. package/src/test/error_objects/flaggedError.spec.ts +0 -22
  123. package/src/test/error_objects/httpError.spec.ts +0 -68
  124. package/src/test/error_objects/httpErrorNoStack.spec.ts +0 -64
  125. package/src/test/error_objects/operationError.spec.ts +0 -152
  126. package/src/test/guidUtils.spec.ts +0 -213
  127. package/src/test/strings/joinPaths.spec.ts +0 -17
  128. package/src/test/tsconfig.json +0 -21
  129. package/tsconfig.esnext.tsbuildinfo +0 -824
  130. package/tsconfig.tsbuildinfo +0 -823
@@ -1,128 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /* eslint-disable no-unused-expressions */
6
- /**
7
- * @fileoverview In this file, we will test the functions exported by datastructres/collection.js
8
- */
9
-
10
- import semver from "semver";
11
- import { expect } from "chai";
12
- import { SortedCollection } from "../../index";
13
-
14
- describe("SortedCollection", function() {
15
- let collection;
16
- beforeEach(function() {
17
- collection = new SortedCollection();
18
- collection.setComparisonFunction(function(a, b) {
19
- if (semver.gt(a, b)) {
20
- return 1;
21
- } else if (semver.lt(a, b)) {
22
- return -1;
23
- }
24
-
25
- return 0;
26
- });
27
-
28
- collection.bulkAdd({
29
- "2.0.0": "2.0.0",
30
- "1.1.0": "1.1.0",
31
- "1.2.1": "1.2.1",
32
- "1.10.5": "1.10.5",
33
- "3.0.0": "3.0.0",
34
- "101.203.345": "101.203.345",
35
- "4.0.0": "4.0.0",
36
- "2.1.0": "2.1.0",
37
- });
38
- });
39
-
40
- it("should always sort the order of the keys after altering the collection", function() {
41
- expect(collection._sortedKeys).to.eql(
42
- ["1.1.0", "1.2.1", "1.10.5", "2.0.0", "2.1.0", "3.0.0", "4.0.0", "101.203.345"],
43
- );
44
-
45
- collection.remove("2.0.0");
46
-
47
- expect(collection._sortedKeys).to.eql(
48
- ["1.1.0", "1.2.1", "1.10.5", "2.1.0", "3.0.0", "4.0.0", "101.203.345"],
49
- );
50
-
51
- collection.bulkAdd({
52
- "5.0.0": "5.0.0",
53
- "0.0.1": "0.0.1",
54
- "2.3.9": "2.3.9",
55
- });
56
-
57
- expect(collection._sortedKeys).to.eql([
58
- "0.0.1", "1.1.0", "1.2.1", "1.10.5", "2.1.0", "2.3.9", "3.0.0", "4.0.0", "5.0.0", "101.203.345",
59
- ]);
60
-
61
- collection.bulkRemove({
62
- "5.0.0": "5.0.0",
63
- "0.0.1": "0.0.1",
64
- "2.3.9": "2.3.9",
65
- });
66
-
67
- expect(collection._sortedKeys).to.eql(["1.1.0", "1.2.1", "1.10.5", "2.1.0", "3.0.0", "4.0.0", "101.203.345"]);
68
- });
69
-
70
- it("should test against adding values for keys that are of type number or string", function() {
71
- const collection2 = new SortedCollection<string>();
72
- collection2.add("6.0.0", "6.0.0");
73
- collection2.add(6.0, "6.0");
74
- collection2.add(6.2, "6.2");
75
- expect(collection2.item("6.0.0")).to.equal("6.0.0");
76
- expect(collection2.item(6.0)).to.equal("6.0");
77
- expect(collection2.item("6")).to.equal("6.0");
78
- expect(collection2.item(6.2)).to.equal("6.2");
79
- expect(collection2.item("6.2")).to.equal("6.2");
80
- });
81
-
82
- it("should get the nearest next item in the collection", function() {
83
- let nearestNextItem = collection.getNearestNextItem("0.0.1");
84
- expect(nearestNextItem).to.equal("1.1.0");
85
-
86
- nearestNextItem = collection.getNearestNextItem("5.0.0");
87
- expect(nearestNextItem).to.equal("101.203.345");
88
-
89
- nearestNextItem = collection.getNearestNextItem("201.203.345");
90
- expect(nearestNextItem).to.equal(undefined);
91
-
92
- nearestNextItem = collection.getNearestNextItem("2.0.1");
93
- expect(nearestNextItem).to.equal("2.1.0");
94
-
95
- nearestNextItem = collection.getNearestNextItem("2.1.1");
96
- expect(nearestNextItem).to.equal("3.0.0");
97
-
98
- nearestNextItem = collection.getNearestNextItem("3.0.0");
99
- expect(nearestNextItem).to.equal("3.0.0");
100
- });
101
-
102
- it("should get the nearest previous item in the collection", function() {
103
- let nearestNextItem = collection.getNearestPreviousItem("0.0.1");
104
- expect(nearestNextItem).to.equal(undefined);
105
-
106
- nearestNextItem = collection.getNearestPreviousItem("5.0.0");
107
- expect(nearestNextItem).to.equal("4.0.0");
108
-
109
- nearestNextItem = collection.getNearestPreviousItem("201.203.345");
110
- expect(nearestNextItem).to.equal("101.203.345");
111
-
112
- nearestNextItem = collection.getNearestPreviousItem("2.0.1");
113
- expect(nearestNextItem).to.equal("2.0.0");
114
-
115
- nearestNextItem = collection.getNearestPreviousItem("2.1.1");
116
- expect(nearestNextItem).to.equal("2.1.0");
117
-
118
- nearestNextItem = collection.getNearestNextItem("3.0.0");
119
- expect(nearestNextItem).to.equal("3.0.0");
120
- });
121
-
122
- it("should clone the sorted collection", function() {
123
- const clone = collection.clone();
124
- expect(clone instanceof SortedCollection).to.equal(true);
125
- expect(clone._sortedKeys).
126
- to.eql(["1.1.0", "1.2.1", "1.10.5", "2.0.0", "2.1.0", "3.0.0", "4.0.0", "101.203.345"]);
127
- });
128
- });
@@ -1,18 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /**
7
- * @fileoverview In this file,we will test property-common.DeterministicRandomGenerator
8
- */
9
-
10
- import { expect } from "chai";
11
- import { DeterministicRandomGenerator } from "../deterministicRandomGenerator";
12
-
13
- describe("property-common.DeterministicRandomGenerator", function() {
14
- it("should exist", function() {
15
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
16
- expect(DeterministicRandomGenerator).to.exist;
17
- });
18
- });
@@ -1,22 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /* eslint-disable max-nested-callbacks */
6
- /**
7
- * @fileoverview Tests the functions exported by error_objects/http_error.js
8
- */
9
-
10
- import { expect } from "chai";
11
- import { FlaggedError } from "../..";
12
-
13
- describe("property-common.FlaggedError", function() {
14
- describe("Flags", function() {
15
- it("can be extended", function(done) {
16
- Object.keys(FlaggedError.FLAGS).forEach(function(key, index) {
17
- expect(FlaggedError.FLAGS[key]).to.equal(Math.pow(2, index));
18
- });
19
- done();
20
- });
21
- });
22
- });
@@ -1,68 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /**
7
- * @fileoverview Tests the functions exported by error_objects/http_error.js
8
- */
9
-
10
- import { expect } from "chai";
11
- import { HTTPError } from "../..";
12
-
13
- describe("property-common.HTTPError", function() {
14
- const errorMsg = "a test error message";
15
-
16
- describe("object", function() {
17
- it("is instanceof Error", function(done) {
18
- expect(new HTTPError() instanceof Error).to.equal(true);
19
- done();
20
- });
21
-
22
- it("is instanceof HTTPError", function(done) {
23
- expect(new HTTPError() instanceof HTTPError).to.equal(true);
24
- done();
25
- });
26
- });
27
-
28
- describe("toString", function() {
29
- it("basic error message", function(done) {
30
- const actual = new HTTPError(errorMsg);
31
- expect(actual.toString()).to.have.string(errorMsg);
32
- done();
33
- });
34
- });
35
-
36
- describe("JSON.stringify", function() {
37
- it("stringifies", function(done) {
38
- const actual = JSON.stringify(new HTTPError(errorMsg));
39
- expect(actual).to.have.string(errorMsg);
40
- done();
41
- });
42
- });
43
-
44
- describe("flags", function() {
45
- it("default at 0", function(done) {
46
- const actual = new HTTPError(errorMsg);
47
- expect(actual.flags).to.equal(0);
48
- done();
49
- });
50
-
51
- it("can be quiet", function(done) {
52
- const actual = new HTTPError(errorMsg, undefined, undefined, undefined, undefined, HTTPError.FLAGS.QUIET);
53
- expect(actual.isQuiet()).to.equal(true);
54
- expect(actual.flags).to.equal(HTTPError.FLAGS.QUIET);
55
- done();
56
- });
57
-
58
- it("can be extended", function(done) {
59
- const actual =
60
- // eslint-disable-next-line no-bitwise
61
- new HTTPError(errorMsg, undefined, undefined, undefined, undefined, HTTPError.FLAGS.QUIET | 4);
62
- expect(actual.isQuiet()).to.equal(true);
63
- // eslint-disable-next-line no-bitwise
64
- expect(actual.flags).to.equal(HTTPError.FLAGS.QUIET | 4);
65
- done();
66
- });
67
- });
68
- });
@@ -1,64 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /* eslint-disable no-bitwise */
7
- /* globals assert */
8
- /**
9
- * @fileoverview Tests the functions exported by error_objects/http_error_no_stack.js
10
- */
11
-
12
- import { expect } from "chai";
13
- import { HTTPError, HTTPErrorNoStack } from "../../index";
14
-
15
- describe("property-common.HTTPErrorNoStack", function() {
16
- const errorMsg = "a test error message";
17
-
18
- describe("object", function() {
19
- it("is instanceof Error", function(done) {
20
- expect(new HTTPErrorNoStack() instanceof Error).to.equal(true);
21
- done();
22
- });
23
-
24
- it("is instanceof HTTPError", function(done) {
25
- expect(new HTTPErrorNoStack() instanceof HTTPError).to.equal(true);
26
- done();
27
- });
28
-
29
- it("is instanceof HTTPErrorNoStack", function(done) {
30
- expect(new HTTPErrorNoStack() instanceof HTTPErrorNoStack).to.equal(true);
31
- done();
32
- });
33
-
34
- it("has no stack parameter", function(done) {
35
- const httpErrorNoStack = new HTTPErrorNoStack(errorMsg);
36
- expect(httpErrorNoStack.stack).to.equal(undefined);
37
- done();
38
- });
39
- });
40
-
41
- describe("flags", function() {
42
- it("default at 0", function(done) {
43
- const actual = new HTTPErrorNoStack(errorMsg);
44
- expect(actual.flags).to.equal(0);
45
- done();
46
- });
47
-
48
- it("can be quiet", function(done) {
49
- const actual = new HTTPErrorNoStack(errorMsg, undefined, undefined, undefined, undefined,
50
- HTTPErrorNoStack.FLAGS.QUIET);
51
- expect(actual.isQuiet()).to.equal(true);
52
- expect(actual.flags).to.equal(HTTPErrorNoStack.FLAGS.QUIET);
53
- done();
54
- });
55
-
56
- it("can be extended", function(done) {
57
- const actual = new HTTPErrorNoStack(errorMsg, undefined, undefined, undefined, undefined,
58
- HTTPErrorNoStack.FLAGS.QUIET | 4);
59
- expect(actual.isQuiet()).to.equal(true);
60
- expect(actual.flags).to.equal(HTTPErrorNoStack.FLAGS.QUIET | 4);
61
- done();
62
- });
63
- });
64
- });
@@ -1,152 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /* eslint-disable no-bitwise */
7
-
8
- /**
9
- * @fileoverview Tests the functions exported by error_objects/operation_error.js
10
- */
11
-
12
- import { expect } from "chai";
13
- import { OperationError } from "../../index";
14
-
15
- describe("property-common.OperationError", function() {
16
- const errorMsg = "a test error message";
17
- const operation = "TestOperation";
18
-
19
- describe("object", function() {
20
- it("is instanceof Error", function(done) {
21
- expect(new OperationError() instanceof Error).to.equal(true);
22
- done();
23
- });
24
-
25
- it("is instanceof OperationError", function(done) {
26
- expect(new OperationError() instanceof OperationError).to.equal(true);
27
- done();
28
- });
29
-
30
- it("stringifies", function(done) {
31
- const actual = JSON.stringify(new OperationError(errorMsg));
32
- const expected = '{"flags":0,"name":"OperationError"}';
33
- expect(actual).to.equal(expected);
34
- done();
35
- });
36
- });
37
-
38
- describe("toString", function() {
39
- it("basic error message", function(done) {
40
- const expected = `OperationError: ${errorMsg}`;
41
- const actual = new OperationError(errorMsg).toString();
42
- expect(actual).to.not.equal(undefined);
43
- expect(actual).to.have.string(expected);
44
- done();
45
- });
46
-
47
- it("full OperationError", function(done) {
48
- const code = 99;
49
- const expected = `OperationError[${operation}, ${code}, 1 [TRANSIENT]]: ${errorMsg}`;
50
- const actual = new OperationError(errorMsg, operation, code, OperationError.FLAGS.TRANSIENT);
51
- expect(actual.toString()).to.have.string(expected);
52
- done();
53
- });
54
-
55
- it("partial OperationError", function(done) {
56
- const expected = `OperationError[${operation}]: ${errorMsg}`;
57
- const actual = new OperationError(errorMsg, operation);
58
- expect(actual.toString()).to.have.string(expected);
59
- done();
60
- });
61
-
62
- it("code only", function(done) {
63
- const code = 99;
64
- const expected = `OperationError[${code}]: ${errorMsg}`;
65
- const actual = new OperationError(errorMsg, undefined, code);
66
- expect(actual.toString()).to.have.string(expected);
67
- done();
68
- });
69
-
70
- it("extended flags", function(done) {
71
- const code = 99;
72
- const expected = `OperationError[${operation}, ${code}, 5 [TRANSIENT]]: ${errorMsg}`;
73
- const actual = new OperationError(errorMsg, operation, code, OperationError.FLAGS.TRANSIENT | 4);
74
- expect(actual.toString()).to.have.string(expected);
75
- done();
76
- });
77
- });
78
-
79
- describe("fields", function() {
80
- it("name", function(done) {
81
- const actual = new OperationError();
82
- expect(actual.name).to.equal("OperationError");
83
- done();
84
- });
85
-
86
- it("stack", function(done) {
87
- const actual = new OperationError();
88
- expect(actual).to.have.property("stack");
89
- done();
90
- });
91
-
92
- it("operation", function(done) {
93
- const actual = new OperationError(errorMsg, operation);
94
- expect(actual.operation).to.equal(operation);
95
- done();
96
- });
97
-
98
- it("statusCode", function(done) {
99
- const code = 99;
100
- const actual = new OperationError(errorMsg, operation, code);
101
- expect(actual.statusCode).to.equal(code);
102
- done();
103
- });
104
-
105
- it("can set the stack", function(done) {
106
- const e = new OperationError();
107
- const e2 = new Error();
108
- e.stack = e2.stack;
109
- done();
110
- });
111
- });
112
-
113
- describe("flags", function() {
114
- it("default at 0", function(done) {
115
- const actual = new OperationError(errorMsg, operation, undefined, undefined);
116
- expect(actual.flags).to.equal(0);
117
- done();
118
- });
119
-
120
- it("can be transiant", function(done) {
121
- const actual = new OperationError(errorMsg, operation, undefined, OperationError.FLAGS.TRANSIENT);
122
- expect(actual.isTransient()).to.equal(true);
123
- expect(actual.flags).to.equal(OperationError.FLAGS.TRANSIENT);
124
- done();
125
- });
126
-
127
- it("can be quiet", function(done) {
128
- const actual = new OperationError(errorMsg, operation, undefined, OperationError.FLAGS.QUIET);
129
- expect(actual.isQuiet()).to.equal(true);
130
- expect(actual.flags).to.equal(OperationError.FLAGS.QUIET);
131
- done();
132
- });
133
-
134
- it("can be transient and quiet", function(done) {
135
- const actual = new OperationError(errorMsg, operation, undefined, OperationError.FLAGS.TRANSIENT |
136
- OperationError.FLAGS.QUIET);
137
- expect(actual.isTransient()).to.equal(true);
138
- expect(actual.isQuiet()).to.equal(true);
139
- expect(actual.flags).to.equal(OperationError.FLAGS.TRANSIENT | OperationError.FLAGS.QUIET);
140
- done();
141
- });
142
-
143
- it("can be extended", function(done) {
144
- const actual = new OperationError(errorMsg, operation, undefined,
145
- OperationError.FLAGS.TRANSIENT | 4 | OperationError.FLAGS.QUIET);
146
- expect(actual.isTransient()).to.equal(true);
147
- expect(actual.isQuiet()).to.equal(true);
148
- expect(actual.flags).to.equal(OperationError.FLAGS.TRANSIENT | 4 | OperationError.FLAGS.QUIET);
149
- done();
150
- });
151
- });
152
- });
@@ -1,213 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /* eslint max-nested-callbacks: 0 */
7
- /* eslint-disable unicorn/no-unsafe-regex */
8
-
9
- /**
10
- * @fileoverview In this file, we will test the functions exported by guid_utils.js
11
- */
12
-
13
- import { expect } from "chai";
14
- import { GuidUtils } from "../guidUtils";
15
-
16
- const {
17
- initializeGUIDGenerator,
18
- generateGUID,
19
- uint32x4ToGUID,
20
- guidToUint32x4,
21
- base64Tobase16,
22
- base16ToBase64,
23
- combineGuids,
24
- isGUID,
25
- } = GuidUtils;
26
-
27
- const testGuid = function(re, base64) {
28
- describe("generateGuid", function() {
29
- it("should return a GUID", function(done) {
30
- expect(re.test(generateGUID(base64))).to.equal(true);
31
- done();
32
- });
33
- });
34
- };
35
-
36
- const testInitialization = function(firstGuid, base64) {
37
- describe("initializeGUIDGenerator", function() {
38
- // WARNING: All the tests below depend on the first it() results.
39
- let guid1;
40
- let guid2;
41
-
42
- describe("using seed 0", function() {
43
- describe("and enforcing it", function() {
44
- it("should result in correct first GUID", function(done) {
45
- // Initialize with seed 0, enforce initialization
46
- initializeGUIDGenerator(0, true);
47
- guid1 = generateGUID(base64);
48
- guid2 = generateGUID(base64);
49
- expect(guid1).to.equal(firstGuid);
50
- expect(guid2).to.not.equal(firstGuid);
51
- done();
52
- });
53
-
54
- it("should replay the same sequence when called again", function(done) {
55
- // Do it again to confirm that re-initialization does indeed reset the sequence
56
- // and that the first time was not due to testing order.
57
- initializeGUIDGenerator(0, true);
58
- expect(generateGUID(base64)).to.equal(guid1);
59
- expect(generateGUID(base64)).to.equal(guid2);
60
- done();
61
- });
62
- });
63
- describe("without enforcing it", function() {
64
- it("should play a different sequence", function(done) {
65
- // Attempting to re-initialized an already initialized generator should
66
- // have no effect on the sequence.
67
- initializeGUIDGenerator(0);
68
- expect(generateGUID(base64)).to.not.equal(guid1);
69
- expect(generateGUID(base64)).to.not.equal(guid2);
70
- done();
71
- });
72
- });
73
- });
74
-
75
- describe("using 'null' seed and enforcing it", function() {
76
- it("should results in same sequence as seed 0", function(done) {
77
- // Do it again to confirm that re-initialization with 'null' is equivalent to zero.
78
- initializeGUIDGenerator(0, true);
79
- expect(generateGUID(base64)).to.equal(guid1);
80
- expect(generateGUID(base64)).to.equal(guid2);
81
- done();
82
- });
83
- });
84
-
85
- describe("using non-zero seed and enforcing it", function() {
86
- it("should results in a different sequence", function(done) {
87
- initializeGUIDGenerator(1, true);
88
- expect(generateGUID(base64)).to.not.equal(guid1);
89
- expect(generateGUID(base64)).to.not.equal(guid2);
90
- done();
91
- });
92
- });
93
- });
94
- };
95
-
96
- const testCorrectness = function(goodGuid, badGuid) {
97
- describe("isGUID", function() {
98
- it("should check if a GUID is valid", function(done) {
99
- expect(isGUID(goodGuid)).to.equal(true);
100
- expect(isGUID(badGuid)).to.equal(false);
101
- done();
102
- });
103
- });
104
- };
105
-
106
- const testConversion = function(guid, guidArray, base64) {
107
- describe("guidToUint32x4", function() {
108
- it("should check that converting a guid to Uint32x4 is correct", function(done) {
109
- let myGuidArray: any = guidToUint32x4(guid);
110
- console.log(myGuidArray);
111
- myGuidArray = Array.prototype.slice.call(myGuidArray);
112
- expect(myGuidArray).to.eql(guidArray);
113
- done();
114
- });
115
- it("should check that converting a guid to Uint32x4 with parameter array is correct", function(done) {
116
- let ioResult: any = new Uint32Array(4);
117
- let myGuidArray: any = guidToUint32x4(guid, ioResult);
118
- myGuidArray = Array.prototype.slice.call(myGuidArray);
119
- ioResult = Array.prototype.slice.call(ioResult);
120
- expect(ioResult).to.eql(myGuidArray);
121
- done();
122
- });
123
- });
124
-
125
- describe("uint32x4ToGuid", function() {
126
- it("should check that converting a Uint32x4 to guid is correct", function(done) {
127
- const myGuid = uint32x4ToGUID(guidArray, base64);
128
- expect(myGuid).to.equal(guid);
129
- done();
130
- });
131
- });
132
-
133
- describe("uint32x4ToGUID and guidToUint32x4", function() {
134
- it("should check that converting guid to Uint32x4 and back is correct", function(done) {
135
- const myGuidArray = guidToUint32x4(guid);
136
- const guid1 = uint32x4ToGUID(myGuidArray, base64);
137
- expect(guid1).to.equal(guid);
138
- done();
139
- });
140
- });
141
- };
142
-
143
- const testCombine = function(guid1, guid2, expectedGuid, base64) {
144
- describe("combineGuids", function() {
145
- it("should check that combining two guids will result in an expected guid", function() {
146
- expect(combineGuids(guid1, guid2, base64)).to.equal(expectedGuid);
147
- });
148
-
149
- it("should not result in the expected guid if the order of combined guids are reversed", function() {
150
- expect(combineGuids(guid2, guid1, base64)).to.not.equal(expectedGuid);
151
- });
152
- });
153
- };
154
-
155
- const test16fromAndTo64 = function(base64, base16) {
156
- describe("base64Tobase16 and base16ToBase64", function() {
157
- it("should check that converting a base64 to a GUID is correct", function(done) {
158
- expect(base16ToBase64(base64Tobase16(base64))).to.equal(base64);
159
- expect(base64Tobase16(base16ToBase64(base16))).to.equal(base16);
160
- expect(base16ToBase64(base16)).to.equal(base64);
161
- expect(base64Tobase16(base64)).to.equal(base16);
162
- done();
163
- });
164
- });
165
- };
166
-
167
- describe("Base16", function() {
168
- testGuid(/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i, false);
169
- testInitialization("492b176c-bdc9-0dec-7c70-087a6a7bdac2", false);
170
- testCorrectness("893fa0d4-c767-4133-829f-27434bf38cc8", "893fa0d4-c?767-4133-829f-27434b-8");
171
- testConversion("8aecac9a-45d6-8009-0000-00002c033cfb", [2330766490, 1171685385, 0, 738409723], false);
172
- testCombine("4e1170f1-d917-178a-7c8b-dde9b3ba3007", "03b1ed90-a03e-a6cc-fed0-abea5fb52530",
173
- "acd8632c-c214-4fe8-901c-563c0fdbeb12", false);
174
- });
175
-
176
- describe("Base64", function() {
177
- testGuid(/^[\w-]{21}[agqw]$/i, true);
178
- testInitialization("bBcrSewNyb16CHB8wtp7ag", true);
179
- testCorrectness("mqzsigmA1kUAAAAA-zwDLA", "mqzsigmA1kUAAAAA+zw?5$");
180
- testCorrectness("--___---___---___0123w", "--___---___---___01234");
181
- testCorrectness("abcdefgABCDEFG789_-_-w", "abcdefgABCDEFG789_-_-_");
182
- testCorrectness("abcdffffffDEScvF9_-_-g", "abcdffffffDEScvF9_-_-0");
183
- testCorrectness("--___---___---___0123Q", "--___---___---___0123a");
184
- testCorrectness("AAAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAA%AAAAAAA");
185
- testConversion("mqzsigmA1kUAAAAA-zwDLA", [2330766490, 1171685385, 0, 738409723], true);
186
- testConversion("--___---___---___0123Q", [4294963195, 4294950639, 4293917694, 3715517951], true);
187
- testConversion("--___---___---___----g", [4294963195, 4294950639, 4293917694, 4206817279], true);
188
- testConversion("---------------------A", [4223594491, 4026253039, 3203398590, 4173262843], true);
189
- testConversion("AAAAAAAAAAAAAAAAAAAAAA", [0, 0, 0, 0], true);
190
- testConversion("_____________________w", [4294967295, 4294967295, 4294967295, 4294967295], true);
191
- testConversion("abcdefgABCDEFG789_-_-w", [2031990633, 537133304, 4235072708, 4223664119], true);
192
- testConversion("1218LLkdwolw_---__-2ig", [746352087, 2311200185, 3203399536, 2327248895], true);
193
- testConversion("aaMHUi2id94292---__-ww", [1376232297, 3732382253, 3195008822, 3288268795], true);
194
- testConversion("AKKsksoeoeepoep3883e-Q", [2460787200, 3886096074, 2011865513, 4192128499], true);
195
- testConversion("121dsls----_--ww3k339A", [2992467415, 4026220123, 820837311, 4109848030], true);
196
- testCombine("AAAAAEJPQgDSBAAAAAAAAA", "8aecac9a-45d6-8009-0000-00002c033cfb", "IO428cglWJ7Y-mLFMGo9pA", true);
197
- testCombine("AAAAAEJPQgDSBAAAAAAAAA", "mqzsigmA1kUAAAAA-zwDLA", "IO428cglWJ7Y-mLFMGo9pA", true);
198
- testCombine("AAAAAAAAAAAAAAAAAAAAAA", "_____________________w", "qJxUydIxpfHEv7ErjBMm8w", true);
199
- testCombine("00000000-0000-0000-0000-000000000000", "_____________________w", "qJxUydIxpfHEv7ErjBMm8w", true);
200
- testCombine("gggggggggggggggggggggg", "---------------------A", "XFnCZCBvAg8sJ0TwwNuRQg", true);
201
- testCombine("Uiedk4939itkff-___---A", "AKKsksoeoeepoep3883e-Q", "aImthHwnGCgQAHhTbFPr4A", true);
202
- testCombine("1218LLkdwolw_---__-2ig", "aaMHUi2id94292---__-ww", "BZ58EdgKdtckSxx1_NOt1Q", true);
203
- testCombine("AAAAAEJPQgDSBAAAAAAAAA", "8aecac9a-45d6-8009-0000-00002c033cfb", "IO428cglWJ7Y-mLFMGo9pA", true);
204
- testCombine("4e1170f1-d917-178a-7c8b-dde9b3ba3007", "03b1ed90-a03e-a6cc-fed0-abea5fb52530",
205
- "LGPYrOhPFMI8VhyQEuvbDw", true);
206
- testCombine("00000000-0000-0000-0000-000000000000", "ffffffff-8888-9999-0000-aaaaaaaaaaaa",
207
- "qJxUyUD_rnr1ar7Xvb7QSA", true);
208
- });
209
-
210
- test16fromAndTo64("mqzsigmA1kUAAAAA-zwDLA", "8aecac9a-45d6-8009-0000-00002c033cfb");
211
- test16fromAndTo64("AAAAAAAAAAAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000");
212
- test16fromAndTo64("qtqv_f39u7sAq-7uq6urCg", "fdafdaaa-bbbb-fdfd-eeee-ab000aababab");
213
- test16fromAndTo64("_____5mZiIiqqgAAqqqqqg", "ffffffff-8888-9999-0000-aaaaaaaaaaaa");
@@ -1,17 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /* eslint-disable @typescript-eslint/no-unused-expressions */
7
- /**
8
- * @fileoverview In this file,we will test property-common.joinPaths
9
- */
10
- import { expect } from "chai";
11
- import { joinPaths } from "../../index";
12
-
13
- describe("property-common.joinPaths", function() {
14
- it("should exist", function() {
15
- expect(joinPaths).to.exist;
16
- });
17
- });