Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
currencyChoices,
|
||||
matchesChoice,
|
||||
} from '../../resources/js/lib/catalogue-choice.ts';
|
||||
import {
|
||||
createInvestmentHref,
|
||||
preparationSearch,
|
||||
} from '../../resources/js/lib/preparation-intent.ts';
|
||||
|
||||
test('an own investment carries explicit sector, geography and an interval, without an advert or corridor', () => {
|
||||
const path = [
|
||||
{ id: 'province-qa', location_type: 'province' },
|
||||
{ id: 'district-qa', location_type: 'district' },
|
||||
{ id: 'locality-qa', location_type: 'locality' },
|
||||
];
|
||||
const url = new URL(
|
||||
createInvestmentHref(
|
||||
{
|
||||
sector: 'agro',
|
||||
min_amount: '1000000',
|
||||
max_amount: '5000000',
|
||||
currency: 'MZN',
|
||||
q: 'Hotel',
|
||||
corridor_id: 'unrelated',
|
||||
opportunities: [42],
|
||||
},
|
||||
path,
|
||||
),
|
||||
'https://qa.example.test',
|
||||
);
|
||||
assert.equal(url.pathname, '/investimentos/iniciar');
|
||||
assert.equal(url.searchParams.get('investment_budget_min'), '1000000');
|
||||
assert.equal(url.searchParams.get('investment_budget_max'), '5000000');
|
||||
assert.equal(url.searchParams.get('currency'), 'MZN');
|
||||
assert.equal(url.searchParams.get('locality_id'), 'locality-qa');
|
||||
assert.equal(url.searchParams.get('sector'), 'agro');
|
||||
for (const key of [
|
||||
'q',
|
||||
'project_title',
|
||||
'corridor_id',
|
||||
'opportunities',
|
||||
'total_investment',
|
||||
])
|
||||
assert.equal(url.searchParams.has(key), false);
|
||||
const empty = new URL(createInvestmentHref({ q: 'Criar Hotel' }), url);
|
||||
assert.equal(
|
||||
empty.search,
|
||||
'',
|
||||
'a title does not assign a definitive activity or sector',
|
||||
);
|
||||
});
|
||||
|
||||
test('optional opportunity searches use only confirmed criteria and do not carry budget or private declarations', () => {
|
||||
const query = new URLSearchParams(
|
||||
preparationSearch('hotel', 'sector:7', [
|
||||
{ id: 'province-qa', location_type: 'province' },
|
||||
]),
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...query.entries()],
|
||||
[
|
||||
['q', 'hotel'],
|
||||
['sector_id', '7'],
|
||||
['province_id', 'province-qa'],
|
||||
],
|
||||
);
|
||||
assert.equal(preparationSearch('', '', []), '');
|
||||
});
|
||||
|
||||
test('country and currency search accepts names, three letters, accents, case and short codes', () => {
|
||||
for (const query of ['MOC', 'moç', 'MZ', 'mocambique'])
|
||||
assert.equal(matchesChoice(query, ['Moçambique — MZ']), true);
|
||||
const metical = currencyChoices().find((choice) => choice.value === 'MZN');
|
||||
assert.ok(metical);
|
||||
assert.match(metical.label, /metical/i);
|
||||
for (const query of ['MET', 'met', 'MZN'])
|
||||
assert.equal(
|
||||
matchesChoice(query, [metical.label, ...metical.keywords]),
|
||||
true,
|
||||
);
|
||||
assert.deepEqual(
|
||||
currencyChoices(['MZN', 'USD']).map((choice) => choice.value),
|
||||
['MZN', 'USD'],
|
||||
'preserve a consumer’s approved currency constraints',
|
||||
);
|
||||
assert.equal(matchesChoice('euro', [metical.label]), false);
|
||||
});
|
||||
Reference in New Issue
Block a user