Skip to content

Commit

Permalink
test: ensure manifest extra properties are preserved (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 10, 2020
1 parent 4ebcefe commit 0aceb41
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
57 changes: 57 additions & 0 deletions test/__snapshots__/pwa.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,63 @@ Array [
]
`;

exports[`pwa manifest.json 1`] = `
"{
\\"name\\": \\"Test Project Name\\",
\\"short_name\\": \\"@nuxtjs/pwa\\",
\\"description\\": \\"Test Project Description\\",
\\"icons\\": [
{
\\"src\\": \\"/_nuxt/icons/icon_64x64.b8f3a1.png\\",
\\"sizes\\": \\"64x64\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
},
{
\\"src\\": \\"/_nuxt/icons/icon_120x120.b8f3a1.png\\",
\\"sizes\\": \\"120x120\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
},
{
\\"src\\": \\"/_nuxt/icons/icon_144x144.b8f3a1.png\\",
\\"sizes\\": \\"144x144\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
},
{
\\"src\\": \\"/_nuxt/icons/icon_152x152.b8f3a1.png\\",
\\"sizes\\": \\"152x152\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
},
{
\\"src\\": \\"/_nuxt/icons/icon_192x192.b8f3a1.png\\",
\\"sizes\\": \\"192x192\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
},
{
\\"src\\": \\"/_nuxt/icons/icon_384x384.b8f3a1.png\\",
\\"sizes\\": \\"384x384\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
},
{
\\"src\\": \\"/_nuxt/icons/icon_512x512.b8f3a1.png\\",
\\"sizes\\": \\"512x512\\",
\\"type\\": \\"image/png\\",
\\"purpose\\": \\"any maskable\\"
}
],
\\"start_url\\": \\"/?standalone=true\\",
\\"display\\": \\"standalone\\",
\\"background_color\\": \\"#ffffff\\",
\\"lang\\": \\"en\\",
\\"orientation\\": \\"portrait\\"
}"
`;

exports[`pwa sw.js 1`] = `
"const options = {\\"workboxURL\\":\\"https://cdn.jsdelivr.net/npm/workbox-cdn/workbox/workbox-sw.js\\",\\"importScripts\\":[\\"custom-sw.js\\"],\\"config\\":{\\"debug\\":true},\\"cacheNames\\":{\\"prefix\\":\\"test\\",\\"googleAnalytics\\":\\"test-ga\\"},\\"clientsClaim\\":true,\\"skipWaiting\\":true,\\"cleanupOutdatedCaches\\":true,\\"offlineAnalytics\\":true,\\"preCaching\\":[\\"precache.js\\"],\\"runtimeCaching\\":[{\\"urlPattern\\":\\"https://google.com/.*\\",\\"handler\\":\\"CacheFirst\\",\\"method\\":\\"GET\\",\\"strategyPlugins\\":[]},{\\"urlPattern\\":\\"https://pwa.nuxtjs.org/.*\\",\\"handler\\":\\"CacheFirst\\",\\"method\\":\\"GET\\",\\"strategyOptions\\":{\\"cacheName\\":\\"nuxt-pwa\\"},\\"strategyPlugins\\":[{\\"use\\":\\"expiration.ExpirationPlugin\\",\\"config\\":[{\\"maxEntries\\":10,\\"maxAgeSeconds\\":300}]}]},{\\"urlPattern\\":\\"/_nuxt/\\",\\"handler\\":\\"CacheFirst\\",\\"method\\":\\"GET\\",\\"strategyPlugins\\":[]},{\\"urlPattern\\":\\"/\\",\\"handler\\":\\"NetworkFirst\\",\\"method\\":\\"GET\\",\\"strategyPlugins\\":[]}],\\"offlinePage\\":null,\\"pagesURLPattern\\":\\"/\\",\\"offlineStrategy\\":\\"NetworkFirst\\"}
Expand Down
3 changes: 2 additions & 1 deletion test/fixture/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = {
name: 'Test Project Name',
description: 'Test Project Description',
useWebmanifestExtension: true,
fileName: 'manifest_test.[ext]?[hash]'
fileName: 'manifest_test.[ext]?[hash]',
orientation: 'portrait'
},

meta: {
Expand Down
6 changes: 6 additions & 0 deletions test/pwa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ describe('pwa', () => {

expect(swContents.replace(/@[^/]*/, '')).toMatchSnapshot()
})

test('manifest.json', async () => {
const manifestContents = await fs.readFile(path.resolve(nuxt.options.generate.dir, '_nuxt/manifest_test.webmanifest'), 'utf-8')

expect(manifestContents).toMatchSnapshot()
})
})

0 comments on commit 0aceb41

Please sign in to comment.