Skip to content

Commit

Permalink
Moved utils.js tests into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
DenyVeyten committed Sep 20, 2020
1 parent 9bd3759 commit b4d3c1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 0 additions & 8 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ test('apped bg-image to rule', async () => {
expect(result.css).toBe(`a { color: red; background-image: url('${utils.DEFAULT_BASE_URL}?a'); }`);
});

test('trancate long selector to get safe-length url', () => {
const baseUrl = 'base_url';
const longSelector = '.very .long .selector '.repeat(1000);
const result = utils.getSafeUrl(baseUrl, longSelector);

expect(result).toBe(`${baseUrl}?${longSelector}`.substring(0, utils.MAX_URL_LENGTH));
});

test('hash selectors', async () => {
const randomSelector = Math.random().toString(36).substring(1);
const hash = utils.hashString(randomSelector);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Plugin that helps you to find dead css in your project",
"main": "index.js",
"scripts": {
"test": "jest"
"test": "jest --coverage"
},
"repository": {
"type": "git",
Expand Down
9 changes: 9 additions & 0 deletions utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const utils = require('./utils');

test('trancate long selector to get safe-length url', () => {
const baseUrl = 'base_url';
const longSelector = '.very .long .selector '.repeat(1000);
const result = utils.getSafeUrl(baseUrl, longSelector);

expect(result).toBe(`${baseUrl}?${longSelector}`.substring(0, utils.MAX_URL_LENGTH));
});

0 comments on commit b4d3c1e

Please sign in to comment.