Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE]: Modernize Handle-Response-Test #7622

Merged
merged 2 commits into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ module('integration/adapter/handle-response', function (hooks) {
let samplePayload = {
data: [
{
id: 1,
id: '1',
type: 'person',
attributes: {
name: 'John Smith',
},
},
{
id: 2,
id: '2',
type: 'person',
attributes: {
name: 'Zhang San',
Expand All @@ -51,7 +51,7 @@ module('integration/adapter/handle-response', function (hooks) {
};

this.server.get('/people', function () {
return [200, { 'Content-Type': 'application/json' }, JSON.stringify(samplePayload)];
return ['200', { 'Content-Type': 'application/json' }, JSON.stringify(samplePayload)];
});

class TestAdapter extends JSONAPIAdapter {
Expand All @@ -66,7 +66,7 @@ module('integration/adapter/handle-response', function (hooks) {

await this.store.findAll('person');

assert.equal(handleResponseCalled, 1, 'handle response is called');
assert.strictEqual(handleResponseCalled, 1, 'handle response is called');
});

test('handleResponse is called with empty array response', async function (assert) {
Expand All @@ -77,7 +77,7 @@ module('integration/adapter/handle-response', function (hooks) {
};

this.server.get('/people', function () {
return [200, { 'Content-Type': 'application/json' }, JSON.stringify(samplePayload)];
return ['200', { 'Content-Type': 'application/json' }, JSON.stringify(samplePayload)];
});

class TestAdapter extends JSONAPIAdapter {
Expand All @@ -92,14 +92,14 @@ module('integration/adapter/handle-response', function (hooks) {

await this.store.findAll('person');

assert.equal(handleResponseCalled, 1, 'handle response is called');
assert.strictEqual(handleResponseCalled, 1, 'handle response is called');
});

test('handleResponse is called on empty string response', async function (assert) {
let handleResponseCalled = 0;

this.server.get('/people', function () {
return [200, { 'Content-Type': 'application/json' }, ''];
return ['200', { 'Content-Type': 'application/json' }, ''];
});

class TestAdapter extends JSONAPIAdapter {
Expand All @@ -119,14 +119,14 @@ module('integration/adapter/handle-response', function (hooks) {
assert.ok(true, 'promise rejected');
}

assert.equal(handleResponseCalled, 1, 'handle response is called');
assert.strictEqual(handleResponseCalled, 1, 'handle response is called');
});

test('handleResponse is not called on invalid response', async function (assert) {
let handleResponseCalled = 0;

this.server.get('/people', function () {
return [200, { 'Content-Type': 'application/json' }, 'bogus response'];
return ['200', { 'Content-Type': 'application/json' }, 'bogus response'];
});

class TestAdapter extends JSONAPIAdapter {
Expand All @@ -146,14 +146,14 @@ module('integration/adapter/handle-response', function (hooks) {
assert.ok(true, 'promise rejected');
}

assert.equal(handleResponseCalled, 0, 'handle response is not called');
assert.strictEqual(handleResponseCalled, 0, 'handle response is not called');
});

test('handleResponse is called on empty string response with 400 status', async function (assert) {
let handleResponseCalled = 0;

this.server.get('/people', function () {
return [400, { 'Content-Type': 'application/json' }, ''];
return ['400', { 'Content-Type': 'application/json' }, ''];
});

class TestAdapter extends JSONAPIAdapter {
Expand All @@ -173,7 +173,7 @@ module('integration/adapter/handle-response', function (hooks) {
assert.ok(true, 'promise rejected');
}

assert.equal(handleResponseCalled, 1, 'handle response is called');
assert.strictEqual(handleResponseCalled, 1, 'handle response is called');
});

test('handleResponse is called with correct parameters on string response with 422 status', async function (assert) {
Expand All @@ -182,7 +182,7 @@ module('integration/adapter/handle-response', function (hooks) {
let errorObject = { errors: {} };

this.server.get('/people', function () {
return [422, { 'Content-Type': 'application/json' }, JSON.stringify(errorObject)];
return ['422', { 'Content-Type': 'application/json' }, JSON.stringify(errorObject)];
});

class TestAdapter extends JSONAPIAdapter {
Expand All @@ -203,6 +203,6 @@ module('integration/adapter/handle-response', function (hooks) {
assert.ok(true, 'promise rejected');
}

assert.equal(handleResponseCalled, 1, 'handle response is called');
assert.strictEqual(handleResponseCalled, 1, 'handle response is called');
});
});