Skip to content

Commit

Permalink
fix tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanderp committed Nov 20, 2023
1 parent 877c0be commit 65fc9d5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 43 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ A better way of working with the wikidata

## Features

- work with wikidata using classes
- request items from wikidata
- upload the changes
- Work with wikidata using classes
- Request items from wikidata
- Upload the changes

## Getting Started

```bash
npm i --save iwf
```

you can easily request an item from wikidata and list all the labels.
You can easily request an item from wikidata and list all the labels.

```typescript
import {requestItem} from 'iwf';
Expand Down Expand Up @@ -49,7 +49,7 @@ upload(item, {

## Documentation

To see all the functionality, extra documentation and examples, visit [the documentation](https://wvanderp.github.io/iwf/)
To see all the functionality, extra documentation, and examples, visit [the documentation](https://wvanderp.github.io/iwf/)

## License

Expand Down
32 changes: 0 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"eslint": "eslint --ext ts,js src/ tests/ integration/",
"prepublish": "npm run build",
"test": "jest --testPathIgnorePatterns=\"/integration/\"",
"test:all": "jest",
"test:all": "jest --runInBand",
"coverage": "npm run test -- --coverage",
"coverage:all": "jest --coverage",
"clean": "rimraf lib/ .nyc_output/ coverage/ docs/"
Expand Down
12 changes: 11 additions & 1 deletion tests/utils/api/getToken.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import getToken from '../../../src/utils/api/token';
import getToken, { loginUrl } from '../../../src/utils/api/token';

jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
Expand Down Expand Up @@ -30,4 +30,14 @@ describe('getToken', () => {
// @ts-expect-error testing
await expect(() => getToken('a', 'a', null)).rejects.toThrow();
});

it('should return the correct url', () => {
// normal urls
expect(loginUrl('https://www.wikidata.org')).toBe('https://www.wikidata.org/w/api.php?action=login&format=json');
expect(loginUrl('https://test.wikidata.org')).toBe('https://test.wikidata.org/w/api.php?action=login&format=json');

// urls with a path
expect(loginUrl('https://www.wikidata.org/wiki/Main_Page')).toBe('https://www.wikidata.org/w/api.php?action=login&format=json');
expect(loginUrl('https://test.wikidata.org/wiki/Main_Page')).toBe('https://test.wikidata.org/w/api.php?action=login&format=json');
});
});
8 changes: 5 additions & 3 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"./nyc_output",
"coverage",
"diff",
"tests",
"tests/**/*",
"integration/**/*",
"./test.ts",
"./lib",
"./scrap.ts"
"./scrap*.ts",
"**/*.spec.ts"
],
"filesGlob": [
"./src/**/*.ts"
]
}
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"diff",
"./test.ts",
"./lib",
"./scrap.ts"
"./scrap.ts",
"**/*.spec.ts"
]
}

0 comments on commit 65fc9d5

Please sign in to comment.