-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Timestamp): use timestamps instead of dates in ecotag (#167)
- Loading branch information
1 parent
aa83933
commit 77e4f9d
Showing
33 changed files
with
213 additions
and
112 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
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
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
141 changes: 141 additions & 0 deletions
141
....Cli.WebApp/ClientApp/src/Server/Project/Annotations/AnnotationDispatch.container.spec.js
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,141 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import React from 'react'; | ||
import {resilienceStatus} from "../../shared/Resilience"; | ||
import {init, initialState} from "./Annotation.hook"; | ||
import {reducer} from "./Annotation.reducer"; | ||
|
||
const fetch = () => Promise.resolve({ | ||
"id": "0001", | ||
"name": "Relevé d'information", | ||
"dataSetId": "0004", | ||
"classification": "Publique", | ||
"numberTagToDo": 10, | ||
"createDate": "04/04/2011", | ||
"typeAnnotation": "NER", | ||
"text": "Enim ad ex voluptate culpa non cillum eu mollit nulla ex pariatur duis. Commodo officia deserunt elit sint officia consequat elit laboris tempor qui est ex. Laborum magna id deserunt ut fugiat aute nulla in Lorem pariatur. Nostrud elit consectetur exercitation exercitation incididunt consequat occaecat velit voluptate nostrud sunt. Consectetur velit eu amet minim quis sunt in.", | ||
"labels": [{"name": "Recto", "color": "#212121", "id": 0}, {"name": "Verso", "color": "#ffbb00", "id": 1}, {"name": "Signature", "color": "#f20713", "id": 2}], | ||
"users": [ | ||
{"annotationCounter": 10, | ||
"annotationToBeVerified": 1, | ||
"email": "[email protected]"}, | ||
{"annotationCounter": 24, | ||
"annotationToBeVerified": 5, | ||
"email": "[email protected]"}, | ||
{"annotationCounter": 35, | ||
"annotationToBeVerified": 15, | ||
"email": "[email protected]"} | ||
] | ||
}); | ||
|
||
describe('AnnotationDispatch.container', () => { | ||
const givenUser = {}; | ||
const givenDataset = { | ||
"id": "0001", | ||
"name": "Carte verte", | ||
"type": "Image", | ||
"classification": "Publique", | ||
"numberFiles": 300, | ||
"createDate": "30/10/2019" | ||
}; | ||
const givenProject = { | ||
"id": "0001", | ||
"name": "Relevé d'information", | ||
"dataSetId": "0004", | ||
"classification": "Publique", | ||
"numberTagToDo": 10, | ||
"createDate": new Date("04-04-2011").getTime(), | ||
"typeAnnotation": "NER", | ||
"text": "Enim ad ex voluptate culpa non cillum eu mollit nulla ex pariatur duis. Commodo officia deserunt elit sint officia consequat elit laboris tempor qui est ex. Laborum magna id deserunt ut fugiat aute nulla in Lorem pariatur. Nostrud elit consectetur exercitation exercitation incididunt consequat occaecat velit voluptate nostrud sunt. Consectetur velit eu amet minim quis sunt in.", | ||
"labels": [{"name": "Recto", "color": "#212121", "id": 0}, {"name": "Verso", "color": "#ffbb00", "id": 1}, {"name": "Signature", "color": "#f20713", "id": 2}], | ||
"users": [ | ||
{"annotationCounter": 10, | ||
"annotationToBeVerified": 1, | ||
"email": "[email protected]"}, | ||
{"annotationCounter": 24, | ||
"annotationToBeVerified": 5, | ||
"email": "[email protected]"}, | ||
{"annotationCounter": 35, | ||
"annotationToBeVerified": 15, | ||
"email": "[email protected]"} | ||
] | ||
}; | ||
|
||
function fail(message = "The fail function was called") { | ||
throw new Error(message); | ||
} | ||
|
||
/*it('AnnotationDispatchContainer render correctly', async () => { | ||
const { getByText } = render(<Router><AnnotationDispatchContainer fetch={fetch} user={givenUser}/></Router>); | ||
const messageEl = await waitFor(() => getByText('Soumettre l\'annotation')); | ||
expect(messageEl).toHaveTextContent( | ||
'Soumettre l\'annotation' | ||
); | ||
});*/ | ||
|
||
describe('.reducer()', () => { | ||
it('should set the new fields with asked values after onChange action', () => { | ||
const givenState = {...initialState}; | ||
const givenAction = { | ||
type: 'init', | ||
data: { | ||
project : givenProject, | ||
status: resilienceStatus.LOADING | ||
} | ||
} | ||
|
||
const actualState = reducer(givenState, givenAction); | ||
|
||
expect(actualState).toMatchObject({ | ||
...givenState, | ||
project : givenProject, | ||
}); | ||
}); | ||
it('should throw an error by default', (done) => { | ||
const givenState = {}; | ||
const givenAction = { | ||
type: 'unknown', | ||
} | ||
|
||
try { | ||
reducer(givenState, givenAction); | ||
fail(error); | ||
} catch (error) { | ||
done(); | ||
} | ||
}); | ||
}); | ||
|
||
describe('.init()', () => { | ||
let givenFetch; | ||
let givenDispatch; | ||
let givenFetchRejected; | ||
|
||
beforeEach(() => { | ||
givenFetch = jest.fn(() => Promise.resolve({ok: true, json: () => Promise.resolve(givenProject)})); | ||
givenDispatch = jest.fn(); | ||
givenFetchRejected = jest.fn(() => Promise.reject("ERROR")); | ||
}); | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should call init and dispatch', async () => { | ||
try { | ||
await init(givenFetch, givenDispatch)(givenProject.id); | ||
expect(givenDispatch).toHaveBeenCalledWith( { type: "init", data: { project: givenProject, status: resilienceStatus.SUCCESS } }); | ||
} catch (error) { | ||
fail(error); | ||
} | ||
}); | ||
|
||
it('should fail because of error during init', async () => { | ||
try { | ||
await init(givenFetch, givenDispatch); | ||
fail(error); | ||
} catch (error) { | ||
expect(givenFetch).toHaveBeenCalledTimes(0); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
Oops, something went wrong.