Ajoute projet et migration milestone
Signed-off-by: Gato <cedric@goutailler-olivier.fr>
This commit is contained in:
@@ -28,9 +28,12 @@ describe('IssuesStore', () => {
|
||||
let store: IssuesStore;
|
||||
let httpMock: HttpTestingController;
|
||||
|
||||
const PROJECT_ID = 1;
|
||||
const ISSUES_URL = `${API_BASE_URL}/issues?projectId=${PROJECT_ID}`;
|
||||
|
||||
const loadWith = async (issues: IssueEntity[]) => {
|
||||
const p = store.load();
|
||||
httpMock.expectOne(`${API_BASE_URL}/issues`).flush(issues);
|
||||
const p = store.load(PROJECT_ID);
|
||||
httpMock.expectOne(ISSUES_URL).flush(issues);
|
||||
await p;
|
||||
};
|
||||
|
||||
@@ -57,18 +60,28 @@ describe('IssuesStore', () => {
|
||||
});
|
||||
|
||||
it('sets loading to true during load and false after', async () => {
|
||||
const p = store.load();
|
||||
const p = store.load(PROJECT_ID);
|
||||
expect(store.loading()).toBe(true);
|
||||
httpMock.expectOne(`${API_BASE_URL}/issues`).flush([]);
|
||||
httpMock.expectOne(ISSUES_URL).flush([]);
|
||||
await p;
|
||||
expect(store.loading()).toBe(false);
|
||||
expect(store.loaded()).toBe(true);
|
||||
});
|
||||
|
||||
it('does not reload if already loaded', async () => {
|
||||
it('does not reload if already loaded for the same project', async () => {
|
||||
await loadWith([]);
|
||||
await store.load();
|
||||
httpMock.expectNone(`${API_BASE_URL}/issues`);
|
||||
await store.load(PROJECT_ID);
|
||||
httpMock.expectNone(ISSUES_URL);
|
||||
});
|
||||
|
||||
it('reloads when projectId changes', async () => {
|
||||
await loadWith([makeIssue({ id: 1 })]);
|
||||
const url2 = `${API_BASE_URL}/issues?projectId=2`;
|
||||
const p = store.load(2);
|
||||
httpMock.expectOne(url2).flush([makeIssue({ id: 2 })]);
|
||||
await p;
|
||||
expect(store.issues().length).toBe(1);
|
||||
expect(store.issues()[0].id).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user