|
1 |
| -import { NpmInfo } from "@definitelytyped/utils"; |
2 | 1 | import { createTypingsVersionRaw, testo } from "./utils";
|
3 | 2 | import { GitDiff, getNotNeededPackages, checkNotNeededPackage } from "../src/git";
|
4 | 3 | import { NotNeededPackage, TypesDataFile, AllPackages } from "../src/packages";
|
@@ -65,94 +64,33 @@ testo({
|
65 | 64 | // TODO: Test with dependents, etc etc
|
66 | 65 | });
|
67 | 66 |
|
68 |
| -const empty: NpmInfo = { |
69 |
| - homepage: "", |
70 |
| - distTags: new Map(), |
71 |
| - versions: new Map(), |
72 |
| - time: new Map(), |
73 |
| -}; |
74 | 67 | testo({
|
75 | 68 | missingSource() {
|
76 |
| - expect(() => checkNotNeededPackage(jestNotNeeded[0], undefined, empty)).toThrow( |
| 69 | + return expect(checkNotNeededPackage(new NotNeededPackage("jest", "nonexistent", "100.0.0"))).rejects.toThrow( |
77 | 70 | "The entry for @types/jest in notNeededPackages.json"
|
78 | 71 | );
|
79 | 72 | },
|
80 | 73 | missingTypings() {
|
81 |
| - expect(() => checkNotNeededPackage(jestNotNeeded[0], empty, undefined)).toThrow( |
82 |
| - "@types package not found for @types/jest" |
83 |
| - ); |
84 |
| - }, |
85 |
| - missingTypingsLatest() { |
86 |
| - expect(() => checkNotNeededPackage(jestNotNeeded[0], empty, empty)).toThrow( |
87 |
| - '@types/jest is missing the "latest" tag' |
| 74 | + return expect(checkNotNeededPackage(new NotNeededPackage("nonexistent", "jest", "100.0.0"))).rejects.toThrow( |
| 75 | + "@types package not found for @types/nonexistent" |
88 | 76 | );
|
89 | 77 | },
|
90 | 78 | deprecatedSameVersion() {
|
91 |
| - expect(() => { |
92 |
| - checkNotNeededPackage(jestNotNeeded[0], empty, { |
93 |
| - homepage: "jest.com", |
94 |
| - distTags: new Map([["latest", "100.0.0"]]), |
95 |
| - versions: new Map(), |
96 |
| - time: new Map([["modified", ""]]), |
97 |
| - }); |
98 |
| - }).toThrow(`The specified version 100.0.0 of jest must be newer than the version |
99 |
| -it is supposed to replace, 100.0.0 of @types/jest.`); |
| 79 | + return expect(checkNotNeededPackage(new NotNeededPackage("jest", "jest", "50.0.0"))).rejects |
| 80 | + .toThrow(`The specified version 50.0.0 of jest must be newer than the version |
| 81 | +it is supposed to replace, 50.0.0 of @types/jest.`); |
100 | 82 | },
|
101 | 83 | deprecatedOlderVersion() {
|
102 |
| - expect(() => { |
103 |
| - checkNotNeededPackage(jestNotNeeded[0], empty, { |
104 |
| - homepage: "jest.com", |
105 |
| - distTags: new Map([["latest", "999.0.0"]]), |
106 |
| - versions: new Map(), |
107 |
| - time: new Map([["modified", ""]]), |
108 |
| - }); |
109 |
| - }).toThrow(`The specified version 100.0.0 of jest must be newer than the version |
110 |
| -it is supposed to replace, 999.0.0 of @types/jest.`); |
| 84 | + return expect(checkNotNeededPackage(new NotNeededPackage("jest", "jest", "4.0.0"))).rejects |
| 85 | + .toThrow(`The specified version 4.0.0 of jest must be newer than the version |
| 86 | +it is supposed to replace, 50.0.0 of @types/jest.`); |
111 | 87 | },
|
112 | 88 | missingNpmVersion() {
|
113 |
| - expect(() => { |
114 |
| - checkNotNeededPackage(jestNotNeeded[0], empty, { |
115 |
| - homepage: "jest.com", |
116 |
| - distTags: new Map([["latest", "4.0.0"]]), |
117 |
| - versions: new Map(), |
118 |
| - time: new Map([["modified", ""]]), |
119 |
| - }); |
120 |
| - }).toThrow("The specified version 100.0.0 of jest is not on npm."); |
121 |
| - }, |
122 |
| - olderNpmVersion() { |
123 |
| - expect(() => |
124 |
| - checkNotNeededPackage( |
125 |
| - jestNotNeeded[0], |
126 |
| - { |
127 |
| - homepage: "jest.com", |
128 |
| - distTags: new Map(), |
129 |
| - versions: new Map([["50.0.0", {}]]), |
130 |
| - time: new Map([["modified", ""]]), |
131 |
| - }, |
132 |
| - { |
133 |
| - homepage: "jest.com", |
134 |
| - distTags: new Map([["latest", "4.0.0"]]), |
135 |
| - versions: new Map(), |
136 |
| - time: new Map([["modified", ""]]), |
137 |
| - } |
138 |
| - ) |
139 |
| - ).toThrow("The specified version 100.0.0 of jest is not on npm."); |
| 89 | + return expect(checkNotNeededPackage(new NotNeededPackage("jest", "jest", "999.0.0"))).rejects.toThrow( |
| 90 | + "The specified version 999.0.0 of jest is not on npm." |
| 91 | + ); |
140 | 92 | },
|
141 | 93 | ok() {
|
142 |
| - checkNotNeededPackage( |
143 |
| - jestNotNeeded[0], |
144 |
| - { |
145 |
| - homepage: "jest.com", |
146 |
| - distTags: new Map(), |
147 |
| - versions: new Map([["100.0.0", {}]]), |
148 |
| - time: new Map([["modified", ""]]), |
149 |
| - }, |
150 |
| - { |
151 |
| - homepage: "jest.com", |
152 |
| - distTags: new Map([["latest", "4.0.0"]]), |
153 |
| - versions: new Map(), |
154 |
| - time: new Map([["modified", ""]]), |
155 |
| - } |
156 |
| - ); |
| 94 | + return checkNotNeededPackage(new NotNeededPackage("jest", "jest", "100.0.0")); |
157 | 95 | },
|
158 | 96 | });
|
0 commit comments