-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from kfbfarley/add-resolution
Add resolution feature
- Loading branch information
Showing
6 changed files
with
159 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"width": "1024", | ||
"height": "768" | ||
}, | ||
{ | ||
"width": "2048", | ||
"height": "1536" | ||
}, | ||
{ | ||
"width": "1280", | ||
"height": "800" | ||
}, | ||
{ | ||
"width": "1920", | ||
"height": "1080" | ||
}, | ||
{ | ||
"width": "2560", | ||
"height": "1440" | ||
}, | ||
{ | ||
"width": "3840", | ||
"height": "2160" | ||
}, | ||
{ | ||
"width": "320", | ||
"height": "480" | ||
}, | ||
{ | ||
"width": "750", | ||
"height": "1334" | ||
}, | ||
{ | ||
"width": "1080", | ||
"height": "1920" | ||
}, | ||
{ | ||
"width": "1280", | ||
"height": "720" | ||
}, | ||
{ | ||
"width": "1920", | ||
"height": "1080" | ||
}, | ||
{ | ||
"width": "3840", | ||
"height": "2160" | ||
}, | ||
{ | ||
"width": "2732", | ||
"height": "2048" | ||
}, | ||
{ | ||
"width": "2160", | ||
"height": "1620" | ||
}, | ||
{ | ||
"width": "2560", | ||
"height": "1600" | ||
}, | ||
{ | ||
"width": "3440", | ||
"height": "1440" | ||
}, | ||
{ | ||
"width": "5120", | ||
"height": "2880" | ||
}, | ||
{ | ||
"width": "3840", | ||
"height": "1600" | ||
}, | ||
{ | ||
"width": "2560", | ||
"height": "1080" | ||
}, | ||
{ | ||
"width": "4096", | ||
"height": "2160" | ||
}, | ||
{ | ||
"width": "3840", | ||
"height": "1080" | ||
}, | ||
{ | ||
"width": "2960", | ||
"height": "1440" | ||
}, | ||
{ | ||
"width": "3120", | ||
"height": "1440" | ||
}, | ||
{ | ||
"width": "2560", | ||
"height": "1312" | ||
}, | ||
{ | ||
"width": "3840", | ||
"height": "1200" | ||
}, | ||
{ | ||
"width": "3840", | ||
"height": "2160" | ||
}, | ||
{ | ||
"width": "7680", | ||
"height": "4320" | ||
}, | ||
{ | ||
"width": "5120", | ||
"height": "2160" | ||
} | ||
] | ||
} |
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,24 @@ | ||
import { FakeOptions, fake } from './core/core'; | ||
import { data } from './resolution.json'; | ||
|
||
/** | ||
* Generate random screen resolution | ||
* | ||
* @category internet | ||
* | ||
* @example | ||
* | ||
* randResolution() | ||
* | ||
* @example | ||
* | ||
* randResolution() | ||
* | ||
* | ||
*/ | ||
|
||
export function randResolution<Options extends FakeOptions = never>( | ||
options?: Options | ||
) { | ||
return fake(data, options); | ||
} |
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,16 @@ | ||
import { randResolution } from '../lib/resolution'; | ||
|
||
describe('randResolution', () => { | ||
it('should return an object with properties width and height', () => { | ||
const resolution = randResolution(); | ||
const width = parseInt(resolution.width); | ||
const height = parseInt(resolution.height); | ||
|
||
expect(resolution).toBeTruthy(); | ||
expect(typeof resolution).toBe('object'); | ||
expect(resolution).toHaveProperty('width'); | ||
expect(resolution).toHaveProperty('height'); | ||
expect(Number.isInteger(width)).toBe(true); | ||
expect(Number.isInteger(height)).toBe(true); | ||
}); | ||
}); |