forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
48 changed files
with
975 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/vs/editor/test/node/diffing/fixtures/invalid-diff-bug/1.tst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
const API = require('../src/api'); | ||
|
||
describe('API', () => { | ||
let api; | ||
let database; | ||
|
||
beforeAll(() => { | ||
database = { | ||
getAllBooks: jest.fn(), | ||
getBooksByAuthor: jest.fn(), | ||
getBooksByTitle: jest.fn(), | ||
}; | ||
api = new API(database); | ||
}); | ||
|
||
describe('GET /books', () => { | ||
it('should return all books', async () => { | ||
const mockBooks = [{ title: 'Book 1' }, { title: 'Book 2' }]; | ||
database.getAllBooks.mockResolvedValue(mockBooks); | ||
|
||
const req = {}; | ||
const res = { | ||
json: jest.fn(), | ||
}; | ||
|
||
await api.register({ | ||
get: (path, handler) => { | ||
if (path === '/books') { | ||
handler(req, res); | ||
} | ||
}, | ||
}); | ||
|
||
expect(database.getAllBooks).toHaveBeenCalled(); | ||
expect(res.json).toHaveBeenCalledWith(mockBooks); | ||
}); | ||
}); | ||
|
||
describe('GET /books/author/:author', () => { | ||
it('should return books by author', async () => { | ||
const mockAuthor = 'John Doe'; | ||
const mockBooks = [{ title: 'Book 1', author: mockAuthor }, { title: 'Book 2', author: mockAuthor }]; | ||
database.getBooksByAuthor.mockResolvedValue(mockBooks); | ||
|
||
const req = { | ||
params: { | ||
author: mockAuthor, | ||
}, | ||
}; | ||
const res = { | ||
json: jest.fn(), | ||
}; | ||
|
||
await api.register({ | ||
get: (path, handler) => { | ||
if (path === `/books/author/${mockAuthor}`) { | ||
handler(req, res); | ||
} | ||
}, | ||
}); | ||
|
||
expect(database.getBooksByAuthor).toHaveBeenCalledWith(mockAuthor); | ||
expect(res.json).toHaveBeenCalledWith(mockBooks); | ||
}); | ||
}); | ||
|
||
describe('GET /books/title/:title', () => { | ||
it('should return books by title', async () => { | ||
const mockTitle = 'Book 1'; | ||
const mockBooks = [{ title: mockTitle, author: 'John Doe' }]; | ||
database.getBooksByTitle.mockResolvedValue(mockBooks); | ||
|
||
const req = { | ||
params: { | ||
title: mockTitle, | ||
}, | ||
}; | ||
const res = { | ||
json: jest.fn(), | ||
}; | ||
|
||
await api.register({ | ||
get: (path, handler) => { | ||
if (path === `/books/title/${mockTitle}`) { | ||
handler(req, res); | ||
} | ||
}, | ||
}); | ||
|
||
expect(database.getBooksByTitle).toHaveBeenCalledWith(mockTitle); | ||
expect(res.json).toHaveBeenCalledWith(mockBooks); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.