Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit bc08300

Browse files
committed
test: fix unit test fixtures
1 parent 4688675 commit bc08300

5 files changed

Lines changed: 54 additions & 51 deletions

File tree

test/fixtures/commentListing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export const deeplyNested = {
125125
website: null,
126126
created: 138733525.572392,
127127
modified: null,
128-
total_replies: 1,
128+
total_replies: 0,
129129
hidden_replies: 0,
130130
likes: 0,
131131
dislikes: 0,
@@ -145,7 +145,7 @@ export const deeplyNested = {
145145
website: null,
146146
created: 138733125.572392,
147147
modified: null,
148-
total_replies: 1,
148+
total_replies: 0,
149149
hidden_replies: 0,
150150
likes: 0,
151151
dislikes: 0,

test/unit/CommentList.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ describe('CommentList', () => {
267267
it('can be sorted by multiple criteria', () => {
268268
return pageWithCommentList(SERVER_FIXTURES.forSorting).then(page => {
269269
page.comments.sortBys(
270-
{criterion: SortCriterion.LIKES, mode: SortMode.DESCENDING},
271-
{criterion: SortCriterion.MODIFICATION, mode: SortMode.ASCENDING}
270+
{ criterion: SortCriterion.LIKES, mode: SortMode.DESCENDING },
271+
{ criterion: SortCriterion.MODIFICATION, mode: SortMode.ASCENDING }
272272
);
273273
expect(page.comments.map(toId)).toEqual([4, 6, 5, 2, 1, 3]);
274274
});

test/util/FakeIssoServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class FakeIssoServer extends IssoServer {
2222
delete: stubRegistry;
2323
};
2424

25-
private setStubsToEmpty() {
25+
private setStubsToEmpty(): void {
2626
this.stubs = {
2727
get: {},
2828
post: {},
@@ -122,7 +122,7 @@ export default class FakeIssoServer extends IssoServer {
122122
const stub = jest
123123
.spyOn(request, 'end')
124124
.mockName('request.end')
125-
.mockImplementation(function (this: Http.Request, callback?: RequestCallback): Http.Request {
125+
.mockImplementation(function(this: Http.Request, callback?: RequestCallback): Http.Request {
126126
endStub.call(this, callback || (() => null));
127127
return request;
128128
});

test/util/IssoManagement.ts

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="./hasbin.d.ts" />
1+
// / <reference path="./hasbin.d.ts" />
22

33
/* eslint-env node */
44

@@ -171,8 +171,7 @@ export default class IssoManagement {
171171
}
172172
});
173173
} else {
174-
imageInstall = findDocker()
175-
.then(docker => execAndPrint(`${docker} pull ${ISSO_IMAGE}`));
174+
imageInstall = findDocker().then(docker => execAndPrint(`${docker} pull ${ISSO_IMAGE}`));
176175
}
177176
return imageInstall
178177
.then(() => tmp.dir())
@@ -381,8 +380,7 @@ class Isso {
381380
/**
382381
* Creates a new isso server instance with the given instance id (but does not start it)
383382
*/
384-
public constructor(public readonly id: number) {
385-
}
383+
public constructor(public readonly id: number) {}
386384

387385
/**
388386
* Starts this instance if it’s not already running.
@@ -393,43 +391,48 @@ class Isso {
393391
if (this.process !== undefined) {
394392
return Promise.resolve();
395393
}
396-
return findDocker()
397-
.then(docker => new Promise((resolve, reject) => {
398-
this.process = execFile(
399-
docker,
400-
[
401-
'run',
402-
'--rm',
403-
'--network', 'host',
404-
'-v', `${this.configDir}:/config`,
405-
'-v', `${this.dbDir}:/db`,
406-
ISSO_IMAGE
407-
],
408-
error => {
409-
if (error && !error.killed) {
410-
this.stop().finally(() => reject(error));
394+
return findDocker().then(
395+
docker =>
396+
new Promise((resolve, reject) => {
397+
this.process = execFile(
398+
docker,
399+
[
400+
'run',
401+
'--rm',
402+
'--network',
403+
'host',
404+
'-v',
405+
`${this.configDir}:/config`,
406+
'-v',
407+
`${this.dbDir}:/db`,
408+
ISSO_IMAGE
409+
],
410+
error => {
411+
if (error && !error.killed) {
412+
this.stop().finally(() => reject(error));
413+
}
411414
}
412-
}
413-
);
414-
const startTimeout = setTimeout(
415-
() => this.stop().finally(() => reject('Isso did not start within 20 seconds!')),
416-
20000
417-
);
418-
419-
const startListener = (data: string): void => {
420-
clearTimeout(startTimeout);
421-
this.process?.stderr?.removeListener('data', startListener);
422-
if (!INFO_REGEX.test(data)) {
423-
console.error(data);
424-
this.stop().finally(() => reject(data));
425-
} else if (STARTED_REGEX.test(data)) {
426-
resolve();
427-
}
428-
};
415+
);
416+
const startTimeout = setTimeout(
417+
() => this.stop().finally(() => reject('Isso did not start within 20 seconds!')),
418+
20000
419+
);
420+
421+
const startListener = (data: string): void => {
422+
clearTimeout(startTimeout);
423+
this.process?.stderr?.removeListener('data', startListener);
424+
if (!INFO_REGEX.test(data)) {
425+
console.error(data);
426+
this.stop().finally(() => reject(data));
427+
} else if (STARTED_REGEX.test(data)) {
428+
resolve();
429+
}
430+
};
429431

430-
this.process.stderr?.on('data', startListener);
431-
printSpawned(this.process);
432-
}));
432+
this.process.stderr?.on('data', startListener);
433+
printSpawned(this.process);
434+
})
435+
);
433436
}
434437

435438
/**
@@ -454,7 +457,7 @@ class Isso {
454457
*/
455458
public removeDatabase(): Promise<void> {
456459
return rmrf(this.dbDir).then(() =>
457-
fs.promises.mkdir(this.dbDir, {mode: 0o777, recursive: true})
460+
fs.promises.mkdir(this.dbDir, { mode: 0o777, recursive: true })
458461
);
459462
}
460463

@@ -482,8 +485,8 @@ class Isso {
482485
enabled = false
483486
`.replace(/\t/g, '');
484487
return rmrf(this.configDir)
485-
.then(() => fs.promises.mkdir(this.configDir, {mode: 0o777, recursive: true}))
486-
.then(() => writeFile(`${this.configDir}/isso.conf`, config, {mode: 0o777}));
488+
.then(() => fs.promises.mkdir(this.configDir, { mode: 0o777, recursive: true }))
489+
.then(() => writeFile(`${this.configDir}/isso.conf`, config, { mode: 0o777 }));
487490
}
488491

489492
private get configDir(): string {

test/util/clone.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'clone' {
2-
function clone<T>(o: T): T
2+
function clone<T>(o: T): T;
33

4-
export default clone
4+
export default clone;
55
}

0 commit comments

Comments
 (0)