generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-156357 Price-literals - fail gracefully (#2815)
* MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * Trigger Build * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * MWPW-156357 Price-literals - fail gracefully * Trigger Build * MWPW-156357 Price-literals - fail gracefully --------- Co-authored-by: Bozo Jovicic <bozo@hitthecode.com>
- Loading branch information
1 parent
5ad94df
commit 3fd877c
Showing
29 changed files
with
44 additions
and
666 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,44 +1,24 @@ | ||
import { Defaults } from '../src/index.js'; | ||
import { fetchPriceLiterals } from '../src/literals.js'; | ||
|
||
import { mockFetch } from './mocks/fetch.js'; | ||
import { priceLiteralsURL, withLiterals } from './mocks/literals.js'; | ||
import { getPriceLiterals } from '../src/literals.js'; | ||
import { expect } from './utilities.js'; | ||
import { readFile } from '@web/test-runner-commands'; | ||
|
||
describe('function "fetchPriceLiterals"', () => { | ||
beforeEach(async () => { | ||
await mockFetch(withLiterals); | ||
}); | ||
|
||
it('throws if settings argument does not have `priceLiteralsURL` nor `priceLiteralsPromise` property', async () => { | ||
// @ts-ignore | ||
expect(fetchPriceLiterals({})).eventually.be.rejected; | ||
}); | ||
|
||
it('returns literals from promise', async () => { | ||
const priceLiteralsPromise = new Promise((resolve) => | ||
resolve([ | ||
{ | ||
lang: 'en', | ||
recurrenceLabel: | ||
'{recurrenceTerm, select, MONTH {/mo} YEAR {/yr} other {}}', | ||
}, | ||
]), | ||
); | ||
describe('function "getPriceLiterals"', () => { | ||
it('returns literals', async () => { | ||
const priceLiterals = await (readFile({ path: '../price-literals.json' })); | ||
// @ts-ignore | ||
const literals = await fetchPriceLiterals({ | ||
const literals = await getPriceLiterals({ | ||
language: 'en', | ||
priceLiteralsPromise, | ||
}); | ||
}, JSON.parse(priceLiterals)); | ||
expect(literals.lang).to.equal(Defaults.language); | ||
}); | ||
|
||
it('returns literals for default language if requested does not exist', async () => { | ||
const priceLiterals = await (readFile({ path: '../price-literals.json' })); | ||
// @ts-ignore | ||
const literals = await fetchPriceLiterals({ | ||
const literals = await getPriceLiterals({ | ||
language: 'test', | ||
priceLiteralsURL, | ||
}); | ||
}, JSON.parse(priceLiterals)); | ||
expect(literals.lang).to.equal(Defaults.language); | ||
}); | ||
}); |
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.