-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! add todolistimage findbyid and more tests
- Loading branch information
1 parent
09289d8
commit fba488c
Showing
6 changed files
with
115 additions
and
50 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
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
60 changes: 60 additions & 0 deletions
60
examples/todo-list/src/__tests__/integration/todo-list-image.integration.ts
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,60 @@ | ||
import {expect} from '@loopback/testlab'; | ||
import {TodoListApplication} from '../../application'; | ||
import {TodoListImageRepository, TodoListRepository} from '../../repositories'; | ||
import { | ||
givenRunningApplicationWithCustomConfiguration, | ||
givenTodoListImageInstance, | ||
givenTodoListInstance, | ||
givenTodoListRepositories, | ||
} from '../helpers'; | ||
|
||
describe('TodoListApplication', () => { | ||
let app: TodoListApplication; | ||
let todoListImageRepo: TodoListImageRepository; | ||
let todoListRepo: TodoListRepository; | ||
|
||
before(async () => { | ||
app = await givenRunningApplicationWithCustomConfiguration(); | ||
}); | ||
after(() => app.stop()); | ||
|
||
before(async () => { | ||
({todoListRepo, todoListImageRepo} = await givenTodoListRepositories(app)); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await todoListImageRepo.deleteAll(); | ||
}); | ||
|
||
it('includes TodoList in find method result', async () => { | ||
const list = await givenTodoListInstance(todoListRepo); | ||
const image = await givenTodoListImageInstance(todoListImageRepo, { | ||
todoListId: list.id, | ||
}); | ||
|
||
const response = await todoListImageRepo.find({ | ||
include: [{relation: 'todoList'}], | ||
}); | ||
|
||
expect(response[0]).to.containEql(image); | ||
expect(response[0]).to.containEql({ | ||
todoList: list, | ||
}); | ||
}); | ||
|
||
it('includes TodoList in findById result', async () => { | ||
const list = await givenTodoListInstance(todoListRepo, {}); | ||
const image = await givenTodoListImageInstance(todoListImageRepo, { | ||
todoListId: list.id, | ||
}); | ||
|
||
const response = await todoListImageRepo.findById(image.id, { | ||
include: [{relation: 'todoList'}], | ||
}); | ||
|
||
expect(response).to.containEql(image); | ||
expect(response).to.containEql({ | ||
todoList: list, | ||
}); | ||
}); | ||
}); |
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