Skip to content

Commit

Permalink
docs: add example for searchSchool method. Ref #12
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Apr 25, 2023
1 parent a7076f9 commit 948b3bb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ Skolengo.searchSchool({ text: 'Lycée Louise Weiss' }).then(schools => {
console.log(schools)
})
```
**Example**
```js
const {Skolengo} = require('scolengo-api')
Skolengo.searchSchool({ lat: 48.0, lon: 7.0 }).then(schools => {
console.log(schools)
})
```
<a name="Skolengo.getOIDClient"></a>
### Skolengo.getOIDClient(school, redirectUri)
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ export class Skolengo {
* console.log(schools)
* })
* ```
* @example ```js
* const {Skolengo} = require('scolengo-api')
*
* Skolengo.searchSchool({ lat: 48.0, lon: 7.0 }).then(schools => {
* console.log(schools)
* })
* ```
* @async
*/
public static async searchSchool (filter: SchoolFilter, limit = 10, offset = 0): Promise<SkolengoResponseData<School[]>> {
Expand Down
20 changes: 20 additions & 0 deletions tests/School/Schools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,25 @@ describe('Test Schools', () => {
responseType: 'json'
})
})

it('should searchSchool make the right request with GPS', async () => {
await Skolengo.searchSchool({lat: 48.0, lon: 7.0}, 10, 0)
expect(mockedAxios.request).toBeCalledWith({
baseURL: 'https://api.skolengo.com/api/v1/bff-sko-app',
url: '/schools',
method: 'get',
params: {
filter: {
lat: 48.0,
lon: 7.0
},
page: {
limit: 10,
offset: 0
}
},
responseType: 'json'
})
})
})

0 comments on commit 948b3bb

Please sign in to comment.