Skip to content

Commit

Permalink
add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovalov committed Jan 30, 2020
1 parent cc64ce7 commit 10f74ae
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 8 deletions.
44 changes: 38 additions & 6 deletions packages/size-limit/test/__snapshots__/run.test.js.snap
Expand Up @@ -202,18 +202,26 @@ Check out docs for more complicated cases
"
`;

exports[`shows migration guide for npm users, because of yarn 2 1`] = `
" WARN  You need to add size-limit dependency
In order for the plugins to work correctly
npm install --save-dev size-limit
exports[`shows migration guide for npm users: config 1, dep 0 1`] = `
"Install Size Limit preset depends on type of the project
For application, where you send JS bundle directly to users
npm install --save-dev @size-limit/preset-app
For frameworks, components and big libraries
npm install --save-dev @size-limit/preset-big-lib
For small (< 10 KB) libraries
npm install --save-dev @size-limit/preset-small-lib
Check out docs for more complicated cases
https://github.com/ai/size-limit/
You need to add size-limit dependency: npm install --save-dev size-limit
"
`;

exports[`shows migration guide for yarn 2 users 1`] = `
exports[`shows migration guide for npm users: without sl dev dep 1`] = `
" WARN  You need to add size-limit dependency
In order for the plugins to work correctly
[33myarn add --dev size-limit[39m
[33mnpm install --save-dev size-limit[39m
"
`;
Expand All @@ -232,6 +240,30 @@ Check out docs for more complicated cases
"
`;

exports[`shows migration guide for yarn users: config 1, dep 0 1`] = `
"Install Size Limit preset depends on type of the project
For application, where you send JS bundle directly to users
yarn add --dev @size-limit/preset-app
For frameworks, components and big libraries
yarn add --dev @size-limit/preset-big-lib
For small (< 10 KB) libraries
yarn add --dev @size-limit/preset-small-lib
Check out docs for more complicated cases
https://github.com/ai/size-limit/
You need to add size-limit dependency: yarn add --dev size-limit
"
`;

exports[`shows migration guide for yarn users: without sl dev dep 1`] = `
" WARN  You need to add size-limit dependency
In order for the plugins to work correctly
yarn add --dev size-limit
"
`;

exports[`shows size-limit dependency warning 1`] = `""`;

exports[`shows webpack-related help 1`] = `
Expand Down
Empty file.
@@ -0,0 +1,12 @@
{
"name": "file",
"private": true,
"devDependencies": {},
"size-limit": [
{
"path": "index.js",
"limit": "1 KB",
"running": false
}
]
}
Empty file.
@@ -0,0 +1,12 @@
{
"name": "file",
"private": true,
"devDependencies": {},
"size-limit": [
{
"path": "index.js",
"limit": "1 KB",
"running": false
}
]
}
Empty file.
18 changes: 16 additions & 2 deletions packages/size-limit/test/run.test.js
Expand Up @@ -114,14 +114,28 @@ it('shows migration guide for yarn users', async () => {
expect(await error('legacy-yarn')).toMatchSnapshot()
})

it('shows migration guide for yarn 2 users', async () => {
it('shows migration guide for yarn users: without sl dev dep', async () => {
let [process, history] = createProcess('yarn-without-dev-dep')
await run(process)
expect(history.exitCode).toEqual(0)
expect(history.stderr).toMatchSnapshot()
})

it('shows migration guide for npm users, because of yarn 2', async () => {
it('shows migration guide for yarn users: config 1, dep 0', async () => {
let [process, history] = createProcess('yarn-with-config-without-dev')
await run(process)
expect(history.exitCode).toEqual(1)
expect(history.stderr).toMatchSnapshot()
})

it('shows migration guide for npm users: config 1, dep 0', async () => {
let [process, history] = createProcess('npm-with-config-without-dev')
await run(process)
expect(history.exitCode).toEqual(1)
expect(history.stderr).toMatchSnapshot()
})

it('shows migration guide for npm users: without sl dev dep', async () => {
let [process, history] = createProcess('npm-without-dev-dep')
await run(process)
expect(history.exitCode).toEqual(0)
Expand Down

0 comments on commit 10f74ae

Please sign in to comment.