Skip to content

Commit

Permalink
Feature/fix failedtest (#172)
Browse files Browse the repository at this point in the history
fix the failed tests
  • Loading branch information
eherozhao authored Jun 13, 2023
1 parent 459a15b commit 109baef
Show file tree
Hide file tree
Showing 8 changed files with 1,164 additions and 3,046 deletions.
4,126 changes: 1,122 additions & 3,004 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"eslint-plugin-prettier": "^3.1.2",
"file-loader": "^6.2.0",
"jsdoc": "^3.6.10",
"karma": "^6.3.9",
"karma": "^6.3.12",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.2",
"karma-jasmine": "4.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AbstractSpeech {
/**
* Create a new promise that will stop playback and emit messages for this speech.
*
* @param {Function=} onFinish - Funciton to execute once the speech stops.
* @param {Function=} onFinish - Function to execute once the speech stops.
* @param {onError=} onError - Function to execute if the speech encounters an
* error.
* @param {Function=} onInterrupt - Function to execute if the speech is canceled.
Expand Down
32 changes: 16 additions & 16 deletions packages/amazon-sumerian-hosts-core/test/unit/Deferred.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,19 @@ describe('Deferred', () => {
reject();
});

autoRejected.catch();

expect(autoRejected.rejected).toBeTrue();
autoRejected.catch(() => {
expect(autoRejected.rejected).toBeTrue();
});

const manualRejected = new Deferred();

expect(manualRejected.rejected).toBeFalse();

manualRejected.reject();

manualRejected.catch();

expect(manualRejected.rejected).toBeTrue();
manualRejected.catch(() => {
expect(manualRejected.rejected).toBeTrue();
});
});
});

Expand Down Expand Up @@ -267,19 +267,19 @@ describe('Deferred', () => {
reject();
});

autoRejected.catch();

expect(autoRejected.pending).toBeFalse();
autoRejected.catch(() => {
expect(autoRejected.pending).toBeFalse();
});

const manualRejected = new Deferred();

expect(manualRejected.pending).toBeTrue();

manualRejected.reject();

manualRejected.catch();

expect(manualRejected.pending).toBeFalse();
manualRejected.catch(() => {
expect(manualRejected.pending).toBeFalse();
});
});

it('should return false if the promise has been canceled', () => {
Expand Down Expand Up @@ -322,10 +322,10 @@ describe('Deferred', () => {

deferred.reject('error');

deferred.catch();

expect(onReject).toHaveBeenCalledWith('error');
expect(deferred.pending).toBeFalse();
deferred.catch(() => {
expect(onReject).toHaveBeenCalledWith('error');
expect(deferred.pending).toBeFalse();
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ describe('AnimationLayer', () => {

layer._promises.weight.reject();

layer._promises.weight.catch();

expect(layer.weightPending).toBeFalse();
layer._promises.weight.catch(() => {
expect(layer.weightPending).toBeFalse();
});
});

it('should return false if the weight promise has been canceled', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ describe('AbstractState', () => {

state._promises.weight.reject();

state._promises.weight.catch();

expect(state.weightPending).toBeFalse();
state._promises.weight.catch(() => {
expect(state.weightPending).toBeFalse();
});
});

it('should return false if the weight promise has been canceled', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ describeEnvironment('AbstractSpeech', () => {
const promise = speech._createPromise(undefined, onError);

promise.reject('error');
promise.catch();

expect(onError).toHaveBeenCalledWith('error');
promise.catch(() => {
expect(onError).toHaveBeenCalledWith('error');
});
});

it('should not throw an error if the onError argument is not a function', () => {
const promise = speech._createPromise();
const boundPromise = promise.reject.bind(promise, 'error');
boundPromise();
promise.catch();

expect(boundPromise).not.toThrowError(TypeError);
promise.catch(() => {
expect(boundPromise).not.toThrowError(TypeError);
});
});

it("should emit the speaker's interrupt event when the promise resolves by being canceled", done => {
Expand Down Expand Up @@ -127,21 +127,21 @@ describeEnvironment('AbstractSpeech', () => {

it('should set _playing to false when the promise is no longer pending', () => {
speech._playing = true;
let promise = speech._createPromise();
promise.resolve();
const promiseResolve = speech._createPromise();
promiseResolve.resolve();

expect(speech._playing).toBeFalse();

promise = speech._createPromise();
promise.cancel();
const promiseCancel = speech._createPromise();
promiseCancel.cancel();

expect(speech._playing).toBeFalse();

promise = speech._createPromise();
promise.reject('error');
promise.catch();

expect(speech._playing).toBeFalse();
const promiseReject = speech._createPromise();
promiseReject.reject('error');
promiseReject.catch(() => {
expect(speech._playing).toBeFalse();
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,9 @@ describeEnvironment('AbstractTextToSpeechFeature', () => {

tts._promises.volume.reject();

tts._promises.volume.catch();

expect(tts.volumePending).toBeFalse();
tts._promises.volume.catch(() => {
expect(tts.volumePending).toBeFalse();
});
});

it('should return false if the volume promise has been cancelled', () => {
Expand Down

0 comments on commit 109baef

Please sign in to comment.