faker
A set of classes for mocking known data types such as browser history, browser download list, person, domain name, Jira project, GitHub repository, etc.
Installation
Install the library using npm:
npm install @plq/faker
Usage
Domain
Generates an object with random protocol, domain name and TLD.
It's using for generating History, Project, Repository, Tracker and User.
import { Domain } from '@plq/faker'
const domain = new Domain()
domain.getItem()
Or you can generate a domain with predefined data:
new Domain('https://github.com')
new Domain('npmjs.com')
new Domain('development')
Downloads
Generates an array of random download items.
See chrome.downloads.DownloadItem.
import { Downloads } from '@plq/faker'
const downloads = new Downloads()
downloads.getItems()
downloads.getItem()
With predefined data, class accepts an object with type of downloads.DownloadQuery:
new Downloads({
url: 'https://downloads.info',
limit: 100,
startedAfter: new Date('2023-01-01').getTime(),
startedBefore: new Date('2023-01-31').getTime(),
})
History
Generates an array of random history items.
See chrome.history.HistoryItem.
import { History } from '@plq/faker'
const history = new History()
history.getItems()
history.getItem()
With predefined data, class accepts an object with type of history.search.query:
new History({
text: 'https://github.com',
maxResults: 100,
startTime: new Date('2023-01-01').getTime(),
endTime: new Date('2023-01-31').getTime(),
})
Project
Generates an object with random project name.
import { Project } from '@plq/faker'
const project = new Project()
project.getItem()
Repository
Generates an object with random GitHub or Gitlab repository data.
import { Repository } from '@plq/faker'
const repository = new Repository()
repository.getItem()
Repository constructor params:
- user?: MockUserItem,
- project?: MockProjectItem,
- domain?: MockDomainItem
new Repository({
user: new User().getItem(),
project: new Project().getItem(),
domain: new Domain().getItem(),
})
Tracker
Generates an object with random Jira or Youtrack tracker data.
import { Tracker } from '@plq/faker'
const tracker = new Tracker()
tracker.getItem()
Tracker constructor params:
- user?: MockUserItem,
- project?: MockProjectItem,
- domain?: MockDomainItem
new Tracker({
user: new User().getItem(),
project: new Project().getItem(),
domain: new Domain().getItem(),
})
User
Generates an object with random user data.
import { User } from '@plq/faker'
const user = new User()
user.getItem()
User constructor params:
new User(
new Domain().getItem()
)
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please submit an issue or a pull request on the GitHub repository.
License
This library is distributed under the MIT License. See the LICENSE file for more information.
Bug Reports
If you encounter any bugs or issues, please report them on the issue tracker.