Skip to content

Commit

Permalink
chore: replaces with assert.strictEqual
Browse files Browse the repository at this point in the history
- runs yarn lint:fix
  • Loading branch information
Pixelik committed Nov 6, 2023
1 parent 82e416d commit c6af09c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ module.exports = {
env: {
browser: true,
},
globals: {
require: true,
beforeEach: true,
it: true,
describe: true,
afterEach: true,
process: true,
module: true,
},
rules: {
'ember/no-new-mixins': 'off',
'ember/no-jquery': 'error',
Expand Down
18 changes: 9 additions & 9 deletions tests/acceptance/root-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ module('Acceptance: Root', function (hooks) {

await visit('/');

assert.equal(currentRouteName(), 'index');
assert.equal(
assert.strictEqual(currentRouteName(), 'index');
assert.strictEqual(
this.element.querySelector('.fetch').textContent.trim(),
'Hello World! fetch'
);
});

test('posting a string', function (assert) {
server.post('/upload', function (req) {
assert.equal(req.requestBody, 'foo');
assert.strictEqual(req.requestBody, 'foo');
return [
200,
{ 'Content-Type': 'text/json' },
Expand All @@ -50,11 +50,11 @@ module('Acceptance: Root', function (hooks) {
body: 'foo',
})
.then(function (res) {
assert.equal(res.status, 200);
assert.strictEqual(res.status, 200);
return res.json();
})
.then(function (data) {
assert.equal(data.name, 'World');
assert.strictEqual(data.name, 'World');
});
});

Expand All @@ -75,11 +75,11 @@ module('Acceptance: Root', function (hooks) {
body: form,
})
.then(function (res) {
assert.equal(res.status, 200);
assert.strictEqual(res.status, 200);
return res.json();
})
.then(function (data) {
assert.equal(data.name, 'World');
assert.strictEqual(data.name, 'World');
});
});

Expand All @@ -98,11 +98,11 @@ module('Acceptance: Root', function (hooks) {
body: new window.ArrayBuffer(),
})
.then(function (res) {
assert.equal(res.status, 200);
assert.strictEqual(res.status, 200);
return res.json();
})
.then(function (data) {
assert.equal(data.name, 'World');
assert.strictEqual(data.name, 'World');
});
});

Expand Down
36 changes: 20 additions & 16 deletions tests/unit/utils/mung-options-for-fetch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module('Unit | mungOptionsForFetch', function () {
};

const options = mungOptionsForFetch(getOptions);
assert.equal(options.method, 'GET');
assert.strictEqual(options.method, 'GET');
});

test('mungOptionsForFetch sets the method to an uppercase string', function (assert) {
Expand All @@ -81,15 +81,15 @@ module('Unit | mungOptionsForFetch', function () {
};

let options = mungOptionsForFetch(getOptions);
assert.equal(options.method, 'GET');
assert.strictEqual(options.method, 'GET');

const postOptions = {
url: 'https://emberjs.com',
method: 'post',
};

options = mungOptionsForFetch(postOptions);
assert.equal(options.method, 'POST');
assert.strictEqual(options.method, 'POST');
});

test('mungOptionsForFetch adds string query params to the url correctly', function (assert) {
Expand All @@ -102,7 +102,7 @@ module('Unit | mungOptionsForFetch', function () {
};

let options = mungOptionsForFetch(noQueryStringOptions);
assert.equal(
assert.strictEqual(
options.url,
`${baseUrl}?a=1&b=2`,
'url that started without query params has query params'
Expand All @@ -114,7 +114,7 @@ module('Unit | mungOptionsForFetch', function () {
};

options = mungOptionsForFetch(hasQueryStringOptions);
assert.equal(
assert.strictEqual(
options.url,
`${baseUrl}?fastboot=true&a=1&b=2`,
'url that started with query params has more query params'
Expand Down Expand Up @@ -154,7 +154,7 @@ module('Unit | mungOptionsForFetch', function () {

// Tests POST method.
let options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
JSON.stringify(baseOptions.data),
'POST request body correctly set'
Expand All @@ -163,7 +163,7 @@ module('Unit | mungOptionsForFetch', function () {
// Tests PUT method.
baseOptions.type = 'PUT';
options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
JSON.stringify(baseOptions.data),
'PUT request body correctly set'
Expand All @@ -172,7 +172,7 @@ module('Unit | mungOptionsForFetch', function () {
// Tests DELETE method.
baseOptions.type = 'DELETE';
options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
JSON.stringify(baseOptions.data),
'DELETE request has the correct body'
Expand Down Expand Up @@ -204,31 +204,31 @@ module('Unit | mungOptionsForFetch', function () {
};

let options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
undefined,
'GET request does not have a request body'
);

baseOptions.type = 'HEAD';
options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
undefined,
'HEAD request does not have a request body'
);

baseOptions.data = {};
options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
undefined,
'HEAD request does not have a request body when `data` is an empty object'
);

baseOptions.type = 'GET';
options = mungOptionsForFetch(baseOptions);
assert.equal(
assert.strictEqual(
options.body,
undefined,
'GET request does not have a request body when `data` is an empty object'
Expand All @@ -245,7 +245,7 @@ module('Unit | mungOptionsForFetch', function () {
};

const getOptions = mungOptionsForFetch(getData);
assert.equal(
assert.strictEqual(
getOptions.url.indexOf('?'),
-1,
'A question mark is not added if there are no query params to add'
Expand All @@ -258,7 +258,11 @@ module('Unit | mungOptionsForFetch', function () {
};

const postOptions = mungOptionsForFetch(postData);
assert.equal(postOptions.body, '{}', "'options.body' is an empty object");
assert.strictEqual(
postOptions.body,
'{}',
"'options.body' is an empty object"
);
});

test("mungOptionsForFetch sets the request body correctly when 'data' is FormData", function (assert) {
Expand All @@ -272,7 +276,7 @@ module('Unit | mungOptionsForFetch', function () {
};

const postOptions = mungOptionsForFetch(postData);
assert.equal(
assert.strictEqual(
postOptions.body,
formData,
"'options.body' is the FormData passed in"
Expand All @@ -291,7 +295,7 @@ module('Unit | mungOptionsForFetch', function () {
};

const postOptions = mungOptionsForFetch(postData);
assert.equal(
assert.strictEqual(
postOptions.body,
JSON.stringify(data),
"'options.body' is properly converted to a string"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/serialize-query-params-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module('Unit | serializeQueryParams', function () {
};
const queryParamString = serializeQueryParams(body);

assert.equal(
assert.strictEqual(
queryParamString,
'a=1&b=2&c%5Bd%5D=3&c%5Be%5D%5Bf%5D=4&c%5Bg%5D%5B%5D=5&c%5Bg%5D%5B%5D=6&c%5Bg%5D%5B%5D=7'
);
Expand All @@ -43,7 +43,7 @@ module('Unit | serializeQueryParams', function () {
};
const queryParamString = serializeQueryParams(body);

assert.equal(
assert.strictEqual(
queryParamString,
'b=2&c%5Be%5D%5Bf%5D=4&c%5Bg%5D%5B%5D=5&c%5Bg%5D%5B%5D=6&c%5Bg%5D%5B%5D=7&h=&i=0&j=false'
);
Expand Down

0 comments on commit c6af09c

Please sign in to comment.