Skip to content

Commit

Permalink
load-plugins test and snapshot update after #4490 (#5907)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh authored Jun 15, 2018
1 parent 4427cc7 commit 5f8b29c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Array [
},
"resolve": "",
"ssrAPIs": Array [],
"version": "d41d8cd98f00b204e9800998ecf8427e",
"version": "1.0.0",
},
Object {
"browserAPIs": Array [],
Expand Down Expand Up @@ -188,6 +188,7 @@ Array [
},
"resolve": "",
"ssrAPIs": Array [],
"version": "1.0.0",
},
Object {
"browserAPIs": Array [],
Expand All @@ -199,7 +200,7 @@ Array [
},
"resolve": "",
"ssrAPIs": Array [],
"version": "d41d8cd98f00b204e9800998ecf8427e",
"version": "1.0.0",
},
Object {
"browserAPIs": Array [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
const loadPlugins = require(`../index`)

describe(`Load plugins`, () => {
/**
* Replace the resolve path and version string.
* Resolve path will vary depending on platform.
* Version can be updated (we use external plugin in default config).
* Both will cause snapshots to differ.
*/
const replaceFieldsThatCanVary = plugins => plugins.map(plugin => {
return {
...plugin,
resolve: ``,
version: `1.0.0`,
}
})

it(`Load plugins for a site`, async () => {
let plugins = await loadPlugins({ plugins: [] })

// Delete the resolve path as that varies depending
// on platform so will cause snapshots to differ.
plugins = plugins.map(plugin => {
return {
...plugin,
resolve: ``,
}
})
plugins = replaceFieldsThatCanVary(plugins)

expect(plugins).toMatchSnapshot()
})
Expand All @@ -27,14 +34,7 @@ describe(`Load plugins`, () => {

let plugins = await loadPlugins(config)

// Delete the resolve path as that varies depending
// on platform so will cause snapshots to differ.
plugins = plugins.map(plugin => {
return {
...plugin,
resolve: ``,
}
})
plugins = replaceFieldsThatCanVary(plugins)

expect(plugins).toMatchSnapshot()
})
Expand Down

0 comments on commit 5f8b29c

Please sign in to comment.