Skip to content

Commit

Permalink
chore: Change strictEqual to equal (#10140)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktym4a authored Feb 16, 2024
1 parent 7bdcfb7 commit 5ff288f
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 158 deletions.
2 changes: 1 addition & 1 deletion packages/astro-rss/test/pagesGlobToRssItems.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('pagesGlobToRssItems', () => {
},
];

assert.deepStrictEqual(
assert.deepEqual(
items.sort((a, b) => a.pubDate - b.pubDate),
expected
);
Expand Down
18 changes: 9 additions & 9 deletions packages/astro-rss/test/rss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function assertXmlDeepEqual(a, b) {
const parsedA = parseXmlString(a);
const parsedB = parseXmlString(b);

assert.strictEqual(parsedA.err, null);
assert.strictEqual(parsedB.err, null);
assert.deepStrictEqual(parsedA.result, parsedB.result);
assert.equal(parsedA.err, null);
assert.equal(parsedB.err, null);
assert.deepEqual(parsedA.result, parsedB.result);
}

describe('rss', () => {
Expand All @@ -58,7 +58,7 @@ describe('rss', () => {
assertXmlDeepEqual(str, validXmlResult);

const contentType = response.headers.get('Content-Type');
assert.strictEqual(contentType, 'application/xml');
assert.equal(contentType, 'application/xml');
});

it('should be the same string as getRssString', async () => {
Expand All @@ -73,7 +73,7 @@ describe('rss', () => {
const str1 = await response.text();
const str2 = await getRssString(options);

assert.strictEqual(str1, str2);
assert.equal(str1, str2);
});
});

Expand Down Expand Up @@ -223,8 +223,8 @@ describe('getRssString', () => {
link: phpFeedItem.link,
});

assert.strictEqual(res.success, false);
assert.strictEqual(res.error.issues[0].path[0], 'pubDate');
assert.equal(res.success, false);
assert.equal(res.error.issues[0].path[0], 'pubDate');
});

it('should be extendable', () => {
Expand All @@ -236,7 +236,7 @@ describe('getRssString', () => {
} catch (e) {
error = e.message;
}
assert.strictEqual(error, null);
assert.equal(error, null);
});

it('should not fail when an enclosure has a length of 0', async () => {
Expand Down Expand Up @@ -264,6 +264,6 @@ describe('getRssString', () => {
error = e.message;
}

assert.strictEqual(error, null);
assert.equal(error, null);
});
});
31 changes: 14 additions & 17 deletions packages/astro/test/astro-basic.nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('Astro basic build', () => {
const $ = cheerio.load(html);

// will be 1 if element rendered correctly
assert.strictEqual($('#one').length, 1);
assert.equal($('#one').length, 1);
});

it('supports special chars in filename', async () => {
Expand All @@ -108,45 +108,42 @@ describe('Astro basic build', () => {
it('renders the components top-down', async () => {
const html = await fixture.readFile('/order/index.html');
const $ = cheerio.load(html);
assert.strictEqual($('#rendered-order').text(), 'Rendered order: A, B');
assert.equal($('#rendered-order').text(), 'Rendered order: A, B');
});

it('renders markdown in utf-8 by default', async () => {
const html = await fixture.readFile('/chinese-encoding-md/index.html');
const $ = cheerio.load(html);
assert.strictEqual($('h1').text(), '我的第一篇博客文章');
assert.equal($('h1').text(), '我的第一篇博客文章');
});

it('renders MDX in utf-8 by default', async () => {
const html = await fixture.readFile('/chinese-encoding-mdx/index.html');
const $ = cheerio.load(html);
assert.strictEqual($('h1').text(), '我的第一篇博客文章');
assert.equal($('h1').text(), '我的第一篇博客文章');
});

it('Supports void elements whose name is a string (#2062)', async () => {
const html = await fixture.readFile('/input/index.html');
const $ = cheerio.load(html);

// <Input />
assert.strictEqual($('body > :nth-child(1)').prop('outerHTML'), '<input>');
assert.equal($('body > :nth-child(1)').prop('outerHTML'), '<input>');

// <Input type="password" />
assert.strictEqual($('body > :nth-child(2)').prop('outerHTML'), '<input type="password">');
assert.equal($('body > :nth-child(2)').prop('outerHTML'), '<input type="password">');

// <Input type="text" />
assert.strictEqual($('body > :nth-child(3)').prop('outerHTML'), '<input type="text">');
assert.equal($('body > :nth-child(3)').prop('outerHTML'), '<input type="text">');

// <Input type="select"><option>option</option></Input>
assert.strictEqual(
assert.equal(
$('body > :nth-child(4)').prop('outerHTML'),
'<select><option>option</option></select>'
);

// <Input type="textarea">textarea</Input>
assert.strictEqual(
$('body > :nth-child(5)').prop('outerHTML'),
'<textarea>textarea</textarea>'
);
assert.equal($('body > :nth-child(5)').prop('outerHTML'), '<textarea>textarea</textarea>');
});

it('Generates pages that end with .mjs', async () => {
Expand All @@ -159,18 +156,18 @@ describe('Astro basic build', () => {
it('allows file:// urls as module specifiers', async () => {
const html = await fixture.readFile('/fileurl/index.html');
const $ = cheerio.load(html);
assert.strictEqual($('h1').text(), 'WORKS');
assert.equal($('h1').text(), 'WORKS');
});

describe('preview', () => {
it('returns 200 for valid URLs', async () => {
const result = await fixture.fetch('/');
assert.strictEqual(result.status, 200);
assert.equal(result.status, 200);
});

it('returns 404 for invalid URLs', async () => {
const result = await fixture.fetch('/bad-url');
assert.strictEqual(result.status, 404);
assert.equal(result.status, 404);
});
});
});
Expand All @@ -193,7 +190,7 @@ describe('Astro basic development', () => {

it('Renders markdown in utf-8 by default', async () => {
const res = await fixture.fetch('/chinese-encoding-md');
assert.strictEqual(res.status, 200);
assert.equal(res.status, 200);
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('h1').text(), '我的第一篇博客文章');
Expand All @@ -205,7 +202,7 @@ describe('Astro basic development', () => {

it('Renders MDX in utf-8 by default', async () => {
const res = await fixture.fetch('/chinese-encoding-mdx');
assert.strictEqual(res.status, 200);
assert.equal(res.status, 200);
const html = await res.text();
const $ = cheerio.load(html);
assert.equal($('h1').text(), '我的第一篇博客文章');
Expand Down
44 changes: 22 additions & 22 deletions packages/astro/test/astro-children.nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ describe('Component children', () => {

// test 1: Can pass text to Preact components
const $preact = $('#preact');
assert.strictEqual($preact.text().trim(), 'Hello world');
assert.equal($preact.text().trim(), 'Hello world');

// test 2: Can pass text to Vue components
const $vue = $('#vue');
assert.strictEqual($vue.text().trim(), 'Hello world');
assert.equal($vue.text().trim(), 'Hello world');

// test 3: Can pass text to Svelte components
const $svelte = $('#svelte');
assert.strictEqual($svelte.text().trim(), 'Hello world');
assert.equal($svelte.text().trim(), 'Hello world');
});

it('Passes markup children to framework components', async () => {
Expand All @@ -34,15 +34,15 @@ describe('Component children', () => {

// test 1: Can pass markup to Preact components
const $preact = $('#preact h1');
assert.strictEqual($preact.text().trim(), 'Hello world');
assert.equal($preact.text().trim(), 'Hello world');

// test 2: Can pass markup to Vue components
const $vue = $('#vue h1');
assert.strictEqual($vue.text().trim(), 'Hello world');
assert.equal($vue.text().trim(), 'Hello world');

// test 3: Can pass markup to Svelte components
const $svelte = $('#svelte h1');
assert.strictEqual($svelte.text().trim(), 'Hello world');
assert.equal($svelte.text().trim(), 'Hello world');
});

it('Passes multiple children to framework components', async () => {
Expand All @@ -51,48 +51,48 @@ describe('Component children', () => {

// test 1: Can pass multiple children to Preact components
const $preact = $('#preact');
assert.strictEqual($preact.children().length, 2);
assert.strictEqual($preact.children(':first-child').text().trim(), 'Hello world');
assert.strictEqual($preact.children(':last-child').text().trim(), 'Goodbye world');
assert.equal($preact.children().length, 2);
assert.equal($preact.children(':first-child').text().trim(), 'Hello world');
assert.equal($preact.children(':last-child').text().trim(), 'Goodbye world');

// test 2: Can pass multiple children to Vue components
const $vue = $('#vue');
assert.strictEqual($vue.children().length, 2);
assert.strictEqual($vue.children(':first-child').text().trim(), 'Hello world');
assert.strictEqual($vue.children(':last-child').text().trim(), 'Goodbye world');
assert.equal($vue.children().length, 2);
assert.equal($vue.children(':first-child').text().trim(), 'Hello world');
assert.equal($vue.children(':last-child').text().trim(), 'Goodbye world');

// test 3: Can pass multiple children to Svelte components
const $svelte = $('#svelte');
assert.strictEqual($svelte.children().length, 2);
assert.strictEqual($svelte.children(':first-child').text().trim(), 'Hello world');
assert.strictEqual($svelte.children(':last-child').text().trim(), 'Goodbye world');
assert.equal($svelte.children().length, 2);
assert.equal($svelte.children(':first-child').text().trim(), 'Hello world');
assert.equal($svelte.children(':last-child').text().trim(), 'Goodbye world');
});

it('Renders a template when children are not rendered for client components', async () => {
const html = await fixture.readFile('/no-render/index.html');
const $ = cheerio.load(html);

// test 1: If SSR only, no children are rendered.
assert.strictEqual($('#ssr-only').children().length, 0);
assert.equal($('#ssr-only').children().length, 0);

// test 2: If client, and no children are rendered, a template is.
assert.strictEqual(
assert.equal(
$('#client').parent().children().length,
2,
'rendered the client component and a template'
);
assert.strictEqual(
assert.equal(
$('#client').parent().find('template[data-astro-template]').length,
1,
'Found 1 template'
);

// test 3: If client, and children are rendered, no template is.
assert.strictEqual($('#client-render').parent().children().length, 1);
assert.strictEqual($('#client-render').parent().find('template').length, 0);
assert.equal($('#client-render').parent().children().length, 1);
assert.equal($('#client-render').parent().find('template').length, 0);

// test 4: If client and no children are provided, no template is.
assert.strictEqual($('#client-no-children').parent().children().length, 1);
assert.strictEqual($('#client-no-children').parent().find('template').length, 0);
assert.equal($('#client-no-children').parent().children().length, 1);
assert.equal($('#client-no-children').parent().find('template').length, 0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Astro Markdown - frontmatter injection', () => {
);
assert.ok(readingTimes.length > 0);
for (let readingTime of readingTimes) {
assert.notStrictEqual(readingTime, null);
assert.notEqual(readingTime, null);
assert.match(readingTime.text, /^\d+ min read/);
}
});
Expand Down
16 changes: 8 additions & 8 deletions packages/astro/test/astro-markdown-plugins.nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Astro Markdown plugins', () => {
const $ = cheerio.load(html);

// test 1: Added a TOC
assert.strictEqual($('.toc').length, 1);
assert.equal($('.toc').length, 1);

// test 2: Added .title to h1
assert.ok($('#hello-world').hasClass('title'));
Expand All @@ -56,11 +56,11 @@ describe('Astro Markdown plugins', () => {
it('Still applies default plugins when user plugins are provided', async () => {
const gfmHtml = await fixture.readFile('/with-gfm/index.html');
const $1 = cheerio.load(gfmHtml);
assert.strictEqual($1('a[href="https://example.com"]').length, 1);
assert.equal($1('a[href="https://example.com"]').length, 1);

const smartypantsHtml = await fixture.readFile('/with-smartypants/index.html');
const $2 = cheerio.load(smartypantsHtml);
assert.strictEqual($2('p').html(), '“Smartypants” is — awesome');
assert.equal($2('p').html(), '“Smartypants” is — awesome');

testRemark(gfmHtml);
testRehype(gfmHtml, '#github-flavored-markdown-test');
Expand All @@ -71,7 +71,7 @@ describe('Astro Markdown plugins', () => {
const $ = cheerio.load(html);

// test 1: GFM autolink applied correctly
assert.strictEqual($('a[href="https://example.com"]').length, 1);
assert.equal($('a[href="https://example.com"]').length, 1);

testRemark(html);
testRehype(html, '#github-flavored-markdown-test');
Expand All @@ -82,7 +82,7 @@ describe('Astro Markdown plugins', () => {
const $ = cheerio.load(html);

// test 1: smartypants applied correctly
assert.strictEqual($('p').html(), '“Smartypants” is — awesome');
assert.equal($('p').html(), '“Smartypants” is — awesome');

testRemark(html);
testRehype(html, '#smartypants-test');
Expand All @@ -99,7 +99,7 @@ describe('Astro Markdown plugins', () => {
const html = await fixture.readFile('/with-gfm/index.html');
const $ = cheerio.load(html);

assert.strictEqual($('a[href="https://example.com"]').length, 0);
assert.equal($('a[href="https://example.com"]').length, 0);

testRemark(html);
testRehype(html, '#github-flavored-markdown-test');
Expand All @@ -115,7 +115,7 @@ describe('Astro Markdown plugins', () => {
const html = await fixture.readFile('/with-smartypants/index.html');
const $ = cheerio.load(html);

assert.strictEqual($('p').html(), '"Smartypants" is -- awesome');
assert.equal($('p').html(), '"Smartypants" is -- awesome');

testRemark(html);
testRehype(html, '#smartypants-test');
Expand All @@ -124,7 +124,7 @@ describe('Astro Markdown plugins', () => {

function testRehype(html, headingId) {
const $ = cheerio.load(html);
assert.strictEqual($(headingId).length, 1);
assert.equal($(headingId).length, 1);
assert.ok($(headingId).hasClass('title'));
}

Expand Down
11 changes: 4 additions & 7 deletions packages/astro/test/astro-markdown-remarkRehype.nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ describe('Astro Markdown without remark-rehype config', () => {
it('Renders footnotes with default English labels', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
assert.strictEqual($('#footnote-label').text(), 'Footnotes');
assert.strictEqual(
$('.data-footnote-backref').first().attr('aria-label'),
'Back to reference 1'
);
assert.equal($('#footnote-label').text(), 'Footnotes');
assert.equal($('.data-footnote-backref').first().attr('aria-label'), 'Back to reference 1');
});
});

Expand All @@ -41,7 +38,7 @@ describe('Astro Markdown with remark-rehype config', () => {
it('Renders footnotes with values from the configuration', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
assert.strictEqual($('#footnote-label').text(), 'Catatan kaki');
assert.strictEqual($('.data-footnote-backref').first().attr('aria-label'), 'Kembali ke konten');
assert.equal($('#footnote-label').text(), 'Catatan kaki');
assert.equal($('.data-footnote-backref').first().attr('aria-label'), 'Kembali ke konten');
});
});
Loading

0 comments on commit 5ff288f

Please sign in to comment.