Skip to content

Commit

Permalink
fix(utils): rename talgistOrderParser to taglistOrderParser 🤦
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed May 6, 2023
1 parent edb5aa9 commit b0ea4e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const taglistOrderVariants = (taglistOrder) => {
}
};

export function talgistOrderParser(taglistOrder) {
export const taglistOrderParser = (taglistOrder) => {
const orders = taglistOrderVariants(taglistOrder)
.split(';')
.filter((e) => e)
Expand All @@ -261,4 +261,4 @@ export function talgistOrderParser(taglistOrder) {
}, {});

return orders;
}
};
16 changes: 8 additions & 8 deletions test/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { taglistOrderVariants, talgistOrderParser } from '../src/scripts/utils.js';
import { taglistOrderVariants, taglistOrderParser } from '../src/scripts/utils.js';
import { DockerRegistryUIError } from '../src/scripts/error.js';
import assert from 'assert';

Expand Down Expand Up @@ -36,35 +36,35 @@ describe('utils tests', () => {
});
});

describe('talgistOrderParser', () => {
describe('taglistOrderParser', () => {
it('should have default configuration when empty or undefined', () => {
const expected = { numAsc: true, alphaAsc: true, numFirst: true };
assert.deepEqual(talgistOrderParser(), expected);
assert.deepEqual(talgistOrderParser(''), expected);
assert.deepEqual(taglistOrderParser(), expected);
assert.deepEqual(taglistOrderParser(''), expected);
});

it('should parse correctly `num-asc;alpha-asc` and variants', () => {
const expected = { numAsc: true, alphaAsc: true, numFirst: true };
['asc', 'num-asc;alpha-asc', 'num-asc'].forEach((e) =>
assert.deepEqual(talgistOrderParser(e), expected, `wrong result for ${e}`)
assert.deepEqual(taglistOrderParser(e), expected, `wrong result for ${e}`)
);
});

it('should parse correctly `alpha-desc;num-desc` and variants', () => {
const expected = { numAsc: false, alphaAsc: false, numFirst: false };
['desc', 'alpha-desc;num-desc'].forEach((e) =>
assert.deepEqual(talgistOrderParser(e), expected, `wrong result for ${e}`)
assert.deepEqual(taglistOrderParser(e), expected, `wrong result for ${e}`)
);
});

it('should parse correctly `alpha-asc;num-desc` and variants', () => {
const expected = { numAsc: false, alphaAsc: true, numFirst: false };
assert.deepEqual(talgistOrderParser('alpha-asc;num-desc'), expected)
assert.deepEqual(taglistOrderParser('alpha-asc;num-desc'), expected)
});

it('should parse correctly `num-desc;alpha-desc` and variants', () => {
const expected = { numAsc: false, alphaAsc: false, numFirst: true };
assert.deepEqual(talgistOrderParser('num-desc;alpha-desc'), expected)
assert.deepEqual(taglistOrderParser('num-desc;alpha-desc'), expected)
});
});
});

0 comments on commit b0ea4e5

Please sign in to comment.