mirror of
https://github.com/gristlabs/grist-core.git
synced 2025-06-13 20:53:59 +00:00
update NumberFormat test; change webhook test service
This commit is contained in:
parent
bae035b130
commit
eb2dda699e
@ -6,7 +6,14 @@ describe("NumberFormat", function() {
|
|||||||
locale: 'en-US'
|
locale: 'en-US'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// useGrouping became more nuanced in recent node.
|
||||||
|
// Its old 'true' value may now be 'always' or 'auto'.
|
||||||
|
const useGroupingAlways = buildNumberFormat({numMode: 'decimal'}, defaultDocSettings).resolvedOptions().useGrouping as boolean|string;
|
||||||
|
const useGroupingAuto = (useGroupingAlways === 'always') ? 'auto' : true;
|
||||||
|
|
||||||
it("should convert Grist options into Intr.NumberFormat", function() {
|
it("should convert Grist options into Intr.NumberFormat", function() {
|
||||||
|
assert.include([true, 'always'], String(useGroupingAlways));
|
||||||
|
|
||||||
assert.ownInclude(buildNumberFormat({}, defaultDocSettings).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({}, defaultDocSettings).resolvedOptions(), {
|
||||||
minimumFractionDigits: 0,
|
minimumFractionDigits: 0,
|
||||||
maximumFractionDigits: 10,
|
maximumFractionDigits: 10,
|
||||||
@ -17,21 +24,21 @@ describe("NumberFormat", function() {
|
|||||||
minimumFractionDigits: 0,
|
minimumFractionDigits: 0,
|
||||||
maximumFractionDigits: 3,
|
maximumFractionDigits: 3,
|
||||||
style: 'decimal',
|
style: 'decimal',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAlways,
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'percent'}, defaultDocSettings).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'percent'}, defaultDocSettings).resolvedOptions(), {
|
||||||
minimumFractionDigits: 0,
|
minimumFractionDigits: 0,
|
||||||
maximumFractionDigits: 0,
|
maximumFractionDigits: 0,
|
||||||
// style: 'percent', // In node v14.17.0 style is 'decimal' (unclear why)
|
// style: 'percent', // In node v14.17.0 style is 'decimal' (unclear why)
|
||||||
// so we check final formatting instead in this case.
|
// so we check final formatting instead in this case.
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
});
|
});
|
||||||
assert.equal(buildNumberFormat({numMode: 'percent'}, defaultDocSettings).format(0.5), '50%');
|
assert.equal(buildNumberFormat({numMode: 'percent'}, defaultDocSettings).format(0.5), '50%');
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, defaultDocSettings).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, defaultDocSettings).resolvedOptions(), {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'scientific'}, defaultDocSettings).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'scientific'}, defaultDocSettings).resolvedOptions(), {
|
||||||
@ -73,42 +80,42 @@ describe("NumberFormat", function() {
|
|||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'en-NZ'}).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'en-NZ'}).resolvedOptions(), {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'NZD',
|
currency: 'NZD',
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'de-CH'}).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'de-CH'}).resolvedOptions(), {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'CHF',
|
currency: 'CHF',
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'es-AR'}).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'es-AR'}).resolvedOptions(), {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'ARS',
|
currency: 'ARS',
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'zh-TW'}).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'zh-TW'}).resolvedOptions(), {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'TWD',
|
currency: 'TWD',
|
||||||
});
|
});
|
||||||
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'en-AU'}).resolvedOptions(), {
|
assert.ownInclude(buildNumberFormat({numMode: 'currency'}, {locale: 'en-AU'}).resolvedOptions(), {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
useGrouping: true,
|
useGrouping: useGroupingAuto,
|
||||||
currency: 'AUD',
|
currency: 'AUD',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -3483,13 +3483,20 @@ function testDocApi(settings: {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('webhooks related endpoints', async function () {
|
describe('webhooks related endpoints', async function () {
|
||||||
const serving: Serving = await serveSomething(app => {
|
let serving: Serving;
|
||||||
app.use(express.json());
|
before(async function () {
|
||||||
app.post('/200', ({body}, res) => {
|
serving = await serveSomething(app => {
|
||||||
res.sendStatus(200);
|
app.use(express.json());
|
||||||
res.end();
|
app.post('/200', ({body}, res) => {
|
||||||
});
|
res.sendStatus(200);
|
||||||
}, webhooksTestPort);
|
res.end();
|
||||||
|
});
|
||||||
|
}, webhooksTestPort);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(async function () {
|
||||||
|
await serving.shutdown();
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Regression test for old _subscribe endpoint. /docs/{did}/webhooks should be used instead to subscribe
|
Regression test for old _subscribe endpoint. /docs/{did}/webhooks should be used instead to subscribe
|
||||||
@ -4132,10 +4139,6 @@ function testDocApi(settings: {
|
|||||||
}, webhooksTestPort);
|
}, webhooksTestPort);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async function () {
|
|
||||||
await serving.shutdown();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('table endpoints', function () {
|
describe('table endpoints', function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
|
Loading…
Reference in New Issue
Block a user