Skip to content

Commit 6e5fe58

Browse files
authored
[src/test] Revert imports of "assert" and "path" (#326)
- Previous calling code is more readable - Partially reverts #324
1 parent 76efb0a commit 6e5fe58

20 files changed

+97
-97
lines changed

src/test/additionalPropertiesIsBooleanTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -9,8 +9,8 @@ test("Additional Properties is boolean", async () => {
99
const newFile = "src/test/specs/additional-properties/new.json"
1010
const resultStr = await diff.compare(oldFile, newFile)
1111
const result = JSON.parse(resultStr)
12-
const newFilePath = fileUrl(resolve(newFile))
13-
const oldFilePath = fileUrl(resolve(oldFile))
12+
const newFilePath = fileUrl(path.resolve(newFile))
13+
const oldFilePath = fileUrl(path.resolve(oldFile))
1414
const expected = [
1515
{
1616
id: "1001",
@@ -63,5 +63,5 @@ test("Additional Properties is boolean", async () => {
6363
type: "Error"
6464
}
6565
]
66-
deepStrictEqual(result, expected)
66+
assert.deepStrictEqual(result, expected)
6767
})

src/test/commonParametersTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -9,8 +9,8 @@ test("common-parameters", async () => {
99
const newFile = "src/test/specs/common-parameters/new.json"
1010
const resultStr = await diff.compare(oldFile, newFile)
1111
const result = JSON.parse(resultStr)
12-
const newFilePath = fileUrl(resolve(newFile))
13-
const oldFilePath = fileUrl(resolve(oldFile))
12+
const newFilePath = fileUrl(path.resolve(newFile))
13+
const oldFilePath = fileUrl(path.resolve(oldFile))
1414
const expected = [
1515
{
1616
code: "NoVersionChange",
@@ -77,5 +77,5 @@ test("common-parameters", async () => {
7777
type: "Error"
7878
}
7979
]
80-
deepStrictEqual(result, expected)
80+
assert.deepStrictEqual(result, expected)
8181
})

src/test/compatiblePropertiesTest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -12,7 +12,7 @@ test("compatible-properties", async () => {
1212
const file = "src/test/specs/compatible-properties.json"
1313
const resultStr = await diff.compare(file, file)
1414
const result = JSON.parse(resultStr)
15-
const filePath = fileUrl(resolve(file))
15+
const filePath = fileUrl(path.resolve(file))
1616
const expected = [
1717
{
1818
code: "NoVersionChange",
@@ -33,5 +33,5 @@ test("compatible-properties", async () => {
3333
type: "Info"
3434
}
3535
]
36-
deepStrictEqual(result, expected)
36+
assert.deepStrictEqual(result, expected)
3737
})

src/test/expandsAllOfFullCoversTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -9,8 +9,8 @@ test("expands allOf full covers", async () => {
99
const newFile = "src/test/specs/expandsAllOf/new/property_format_change.json"
1010
const resultStr = await diff.compare(oldFile, newFile)
1111
const result = JSON.parse(resultStr)
12-
const newFilePath = fileUrl(resolve(newFile))
13-
const oldFilePath = fileUrl(resolve(oldFile))
12+
const newFilePath = fileUrl(path.resolve(newFile))
13+
const oldFilePath = fileUrl(path.resolve(oldFile))
1414
const expected = [
1515
{
1616
id: "1001",
@@ -157,5 +157,5 @@ test("expands allOf full covers", async () => {
157157
mode: "Addition"
158158
}
159159
]
160-
deepStrictEqual(result, expected)
160+
assert.deepStrictEqual(result, expected)
161161
})

src/test/expandsAllOfModelsTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -9,8 +9,8 @@ test("expands allOf Models", async () => {
99
const newFile = "src/test/specs/expandsAllOf/new/expand_allOf_model.json"
1010
const resultStr = await diff.compare(oldFile, newFile)
1111
const result = JSON.parse(resultStr)
12-
const newFilePath = fileUrl(resolve(newFile))
13-
const oldFilePath = fileUrl(resolve(oldFile))
12+
const newFilePath = fileUrl(path.resolve(newFile))
13+
const oldFilePath = fileUrl(path.resolve(oldFile))
1414
const expected = [
1515
{
1616
id: "1001",
@@ -67,5 +67,5 @@ test("expands allOf Models", async () => {
6767
type: "Error"
6868
}
6969
]
70-
deepStrictEqual(result, expected)
70+
assert.deepStrictEqual(result, expected)
7171
})

src/test/full2ReversedTest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { OpenApiDiff, Messages } from ".."
1+
import * as assert from "assert"
2+
import { Messages, OpenApiDiff } from ".."
33

44
test("full2 reversed", async () => {
55
const source = {
@@ -16,6 +16,6 @@ test("full2 reversed", async () => {
1616
const resultStr = await diff.compare(source.url, target.url, source.tag, target.tag)
1717
const result: Messages = JSON.parse(resultStr)
1818
for (const v of result) {
19-
deepStrictEqual(v.old.location !== undefined || v.new.location !== undefined, true)
19+
assert.deepStrictEqual(v.old.location !== undefined || v.new.location !== undefined, true)
2020
}
2121
})

src/test/full2Test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { OpenApiDiff, Messages } from ".."
1+
import * as assert from "assert"
2+
import { Messages, OpenApiDiff } from ".."
33

44
test("full2", async () => {
55
const source = {
@@ -16,6 +16,6 @@ test("full2", async () => {
1616
const resultStr = await diff.compare(source.url, target.url, source.tag, target.tag)
1717
const result: Messages = JSON.parse(resultStr)
1818
for (const v of result) {
19-
deepStrictEqual(v.old.location !== undefined || v.new.location !== undefined, true)
19+
assert.deepStrictEqual(v.old.location !== undefined || v.new.location !== undefined, true)
2020
}
2121
})

src/test/fullReversedTest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -9,9 +9,9 @@ test("full reversed", async () => {
99
const diff = new OpenApiDiff({})
1010
const resultStr = await diff.compare(oldFile, newFile, "2019", "2019")
1111
const result = JSON.parse(resultStr)
12-
const oldFilePath = fileUrl(resolve("src/test/specs/full/new/openapi.json"))
13-
const oldFilePath2 = fileUrl(resolve("src/test/specs/full/new/openapi2.json"))
14-
const newFilePath = fileUrl(resolve("src/test/specs/full/old/openapi.json"))
12+
const oldFilePath = fileUrl(path.resolve("src/test/specs/full/new/openapi.json"))
13+
const oldFilePath2 = fileUrl(path.resolve("src/test/specs/full/new/openapi2.json"))
14+
const newFilePath = fileUrl(path.resolve("src/test/specs/full/old/openapi.json"))
1515
const expected = [
1616
{
1717
code: "NoVersionChange",
@@ -46,5 +46,5 @@ test("full reversed", async () => {
4646
type: "Error"
4747
}
4848
]
49-
deepStrictEqual(result, expected)
49+
assert.deepStrictEqual(result, expected)
5050
})

src/test/fullTest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { deepStrictEqual } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -9,9 +9,9 @@ test("full", async () => {
99
const diff = new OpenApiDiff({})
1010
const resultStr = await diff.compare(oldFile, newFile, "2019", "2019")
1111
const result = JSON.parse(resultStr)
12-
const newFilePath = fileUrl(resolve("src/test/specs/full/new/openapi.json").replace(/^\//, ""))
13-
const newFilePath2 = fileUrl(resolve("src/test/specs/full/new/openapi2.json"))
14-
const oldFilePath = fileUrl(resolve("src/test/specs/full/old/openapi.json"))
12+
const newFilePath = fileUrl(path.resolve("src/test/specs/full/new/openapi.json").replace(/^\//, ""))
13+
const newFilePath2 = fileUrl(path.resolve("src/test/specs/full/new/openapi2.json"))
14+
const oldFilePath = fileUrl(path.resolve("src/test/specs/full/old/openapi.json"))
1515
const expected = [
1616
{
1717
code: "NoVersionChange",
@@ -46,5 +46,5 @@ test("full", async () => {
4646
type: "Info"
4747
}
4848
]
49-
deepStrictEqual(result, expected)
49+
assert.deepStrictEqual(result, expected)
5050
})

src/test/incompatiblePropertiesTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { fail, equal } from "assert"
2-
import { resolve } from "path"
1+
import * as assert from "assert"
2+
import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

@@ -10,14 +10,14 @@ import { fileUrl } from "./fileUrl"
1010
test("incompatible-properties", async () => {
1111
const diff = new OpenApiDiff({})
1212
const file = "src/test/specs/incompatible-properties.json"
13-
const filePath = fileUrl(resolve(file))
13+
const filePath = fileUrl(path.resolve(file))
1414

1515
try {
1616
await diff.compare(file, file)
17-
fail("expected diff.compare() to throw")
17+
assert.fail("expected diff.compare() to throw")
1818
} catch (error) {
1919
const e = error as Error
20-
equal(
20+
assert.equal(
2121
e.message,
2222
"incompatible properties : bar\n" +
2323
" definitions/FooBarString/properties/bar\n" +

0 commit comments

Comments
 (0)