Skip to content

Commit fc0c7b7

Browse files
committed
Working out index issue
1 parent b1a17f5 commit fc0c7b7

File tree

6 files changed

+152
-105
lines changed

6 files changed

+152
-105
lines changed

Diff for: src/commands/mdn/__fixtures__/responses.ts

-102
This file was deleted.

Diff for: src/commands/mdn/__snapshots__/api.test.ts.snap

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`updatedMDNQuery should work 1`] = `
4+
Array [
5+
Array [
6+
Object {
7+
"embed": Object {
8+
"author": null,
9+
"color": 8638706,
10+
"description": "1. [**Document directive** - CSP document directives are used in a Conten...](https://developer.mozilla.orgGlossary/Document_directive)
11+
2. [**document environment** - When the JavaScript global environment is ...](https://developer.mozilla.orgGlossary/document_environment)
12+
3. [**DOM (Document Object Model)** - The DOM (Document Object Model) is ...](https://developer.mozilla.orgGlossary/DOM)
13+
4. [**Archived open Web documentation** - The documentation listed below ...](https://developer.mozilla.orgArchive/Web)
14+
5. [**Document.documentElement** - Document.documentElement returns the E...](https://developer.mozilla.orgWeb/API/Document/documentElement)
15+
6. [**Document.documentURI** - The documentURI read-only property of the ...](https://developer.mozilla.orgWeb/API/Document/documentURI)
16+
7. [**Document.documentURIObject** - The Document.documentURIObject read-...](https://developer.mozilla.orgWeb/API/Document/documentURIObject)
17+
8. [**Document** - The Document interface represents any web page loaded ...](https://developer.mozilla.orgWeb/API/Document)
18+
9. [**Document()** - The Document constructor creates a new Document obje...](https://developer.mozilla.orgWeb/API/Document/Document)
19+
10. [**@document** - The @document CSS at-rule restricts the style rules c...](https://developer.mozilla.orgWeb/CSS/@document)
20+
21+
:bulb: *react with a number (:one:, :two:, ...) to filter your result*
22+
:neutral_face: *react with \`❌\` to delete*
23+
:point_up: *supports \`!mdn\`, \`!github\`, \`!caniuse\`, \`!npm\`, \`!composer\`, \`!bundlephobia\`, and \`!php\`*
24+
:gear: *issues? feature requests? head over to [github](https://github.com/ljosberinn/webdev-support-bot)*",
25+
"fields": Array [],
26+
"footer": Object {
27+
"iconURL": "https://avatars0.githubusercontent.com/u/7565578",
28+
"text": "10 results found",
29+
},
30+
"title": "MDN results for *Search Term*",
31+
"url": "https://developer.mozilla.org/en-US/search?q=Search%20Term",
32+
},
33+
},
34+
],
35+
]
36+
`;
37+
38+
exports[`updatedMDNQuery should work 2`] = `
39+
Array [
40+
Array [
41+
"https://developer.mozilla.org/Glossary/DOM",
42+
Object {
43+
"embed": null,
44+
},
45+
],
46+
]
47+
`;

Diff for: src/commands/mdn/api.test.ts

+103-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,111 @@
11
import { updatedQueryBuilder } from './api';
22

3-
import { searchResponse } from './__fixtures__/responses';
43
import useData from '../../utils/useData';
54
import { getChosenResult } from '../../utils/discordTools';
65

6+
const searchResponse = {
7+
query: 'document',
8+
locale: 'en-US',
9+
page: 1,
10+
pages: 383,
11+
start: 1,
12+
end: 10,
13+
next:
14+
'https://developer.mozilla.org/api/v1/search/en-US?highlight=false&page=2&q=document',
15+
previous: null,
16+
count: 3823,
17+
filters: [
18+
{
19+
name: 'Topics',
20+
slug: 'topic',
21+
options: [
22+
{
23+
name: 'APIs and DOM',
24+
slug: 'api',
25+
count: 2609,
26+
active: true,
27+
urls: {
28+
active: '/api/v1/search/en-US?highlight=false&q=document&topic=api',
29+
inactive: '/api/v1/search/en-US?highlight=false&q=document',
30+
},
31+
},
32+
],
33+
},
34+
],
35+
documents: [
36+
{
37+
title: 'Document directive',
38+
slug: 'Glossary/Document_directive',
39+
locale: 'en-US',
40+
excerpt:
41+
'CSP document directives are used in a Content-Security-Policy header and govern the properties of a document or worker environment to which a policy applies.',
42+
},
43+
{
44+
title: 'document environment',
45+
slug: 'Glossary/document_environment',
46+
locale: 'en-US',
47+
excerpt:
48+
"When the JavaScript global environment is a window or an iframe, it is called a document environment. A global environment is an environment that doesn't have an outer environment.",
49+
},
50+
{
51+
title: 'DOM (Document Object Model)',
52+
slug: 'Glossary/DOM',
53+
locale: 'en-US',
54+
excerpt:
55+
'The DOM (Document Object Model) is an API that represents and interacts with any HTML or XML document. The DOM is a document model loaded in the browser and representing the document as a node tree, where each node represents part of the document (e.g. an element, text string, or comment).',
56+
},
57+
{
58+
title: 'Archived open Web documentation',
59+
slug: 'Archive/Web',
60+
locale: 'en-US',
61+
excerpt:
62+
'The documentation listed below is archived, obsolete material about open Web topics.',
63+
},
64+
{
65+
title: 'Document.documentElement',
66+
slug: 'Web/API/Document/documentElement',
67+
locale: 'en-US',
68+
excerpt:
69+
'Document.documentElement returns the Element that is the root element of the document (for example, the html element for HTML documents).',
70+
},
71+
{
72+
title: 'Document.documentURI',
73+
slug: 'Web/API/Document/documentURI',
74+
locale: 'en-US',
75+
excerpt:
76+
'The documentURI read-only property of the Document interface returns the document location as a string.',
77+
},
78+
{
79+
title: 'Document.documentURIObject',
80+
slug: 'Web/API/Document/documentURIObject',
81+
locale: 'en-US',
82+
excerpt:
83+
'The Document.documentURIObject read-only property returns an nsIURI object representing the URI of the document.',
84+
},
85+
{
86+
title: 'Document',
87+
slug: 'Web/API/Document',
88+
locale: 'en-US',
89+
excerpt:
90+
"The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.",
91+
},
92+
{
93+
title: 'Document()',
94+
slug: 'Web/API/Document/Document',
95+
locale: 'en-US',
96+
excerpt:
97+
"The Document constructor creates a new Document object that is a web page loaded in the browser and serving as an entry point into the page's content.",
98+
},
99+
{
100+
title: '@document',
101+
slug: 'Web/CSS/@document',
102+
locale: 'en-US',
103+
excerpt:
104+
'The @document CSS at-rule restricts the style rules contained within it based on the URL of the document. It is designed primarily for user-defined style sheets, though it can be used on author-defined style sheets, too.',
105+
},
106+
],
107+
};
108+
7109
describe('updatedMDNQuery', () => {
8110
const mockUseData: jest.MockedFunction<typeof useData> = jest.fn();
9111
const mockChoose: jest.MockedFunction<typeof getChosenResult> = jest.fn();

Diff for: src/commands/mdn/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const updatedQueryBuilder = (
108108
return;
109109
}
110110

111-
const editableUrl = buildDirectUrl(provider, `/` + result.slug);
111+
const editableUrl = buildDirectUrl(provider, result.slug);
112112
await attemptEdit(sentMsg, editableUrl, { embed: null });
113113
} catch (error) {
114114
console.error(error);

Diff for: src/commands/mdn/index.test.ts

Whitespace-only changes.

Diff for: src/utils/urlTools.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const providers: ProviderMap = {
6565
mdn: {
6666
color: 0x83d0f2,
6767
createTitle: (searchTerm: string) => `MDN results for *${searchTerm}*`,
68-
direct: `https://developer.mozilla.org${TERM}`,
68+
direct: `https://developer.mozilla.org/${TERM}`,
6969
help: '!mdn localStorage',
7070
icon: 'https://avatars0.githubusercontent.com/u/7565578',
7171
search: `https://developer.mozilla.org/en-US/search?q=${SEARCH_TERM}`,

0 commit comments

Comments
 (0)