-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f0e022
commit d09b3ad
Showing
2 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Deferred } from '../../src/util/deferred'; | ||
|
||
describe('Tests cached status code', () => { | ||
it('test resolve method', () => { | ||
const deferred = new Deferred(); | ||
|
||
expect(deferred).resolves.toBe(1); | ||
deferred.resolve(1); | ||
}); | ||
|
||
it('test reject method', () => { | ||
const deferred = new Deferred(); | ||
|
||
expect(deferred).rejects.toBe(1); | ||
deferred.reject(1); | ||
}); | ||
|
||
it('test then method', () => { | ||
const deferred = new Deferred(); | ||
|
||
deferred.then((data) => { | ||
expect(data).toBe(1); | ||
}); | ||
|
||
deferred.resolve(1); | ||
}); | ||
|
||
it('test catch method', () => { | ||
const deferred = new Deferred(); | ||
|
||
deferred.catch((data) => { | ||
expect(data).toBe(1); | ||
}); | ||
|
||
deferred.resolve(1); | ||
}); | ||
|
||
it('test finally method', () => { | ||
const deferred = new Deferred<number>(); | ||
|
||
let data: number; | ||
deferred.then((d) => { | ||
data = d; | ||
}); | ||
|
||
deferred.finally(() => { | ||
expect(data).toBe(1); | ||
}); | ||
|
||
deferred.resolve(1); | ||
}); | ||
}); |