Skip to content

Commit

Permalink
use snapshots for json/console reporter tests - closes yarnpkg#278 (y…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian McKenzie authored and bestander committed Sep 15, 2016
1 parent 9499315 commit 06853a7
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 105 deletions.
83 changes: 83 additions & 0 deletions __tests__/reporters/__snapshots__/buffer.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
exports[`test BufferReporter.command 1`] = `
Array [
Object {
"data": "foobar",
"error": false,
"type": "command"
}
]
`;

exports[`test BufferReporter.error 1`] = `
Array [
Object {
"data": "foobar",
"error": true,
"type": "error"
}
]
`;

exports[`test BufferReporter.finished 1`] = `
Array [
Object {
"data": 0,
"error": false,
"type": "finished"
}
]
`;

exports[`test BufferReporter.info 1`] = `
Array [
Object {
"data": "foobar",
"error": false,
"type": "info"
}
]
`;

exports[`test BufferReporter.log 1`] = `
Array [
Object {
"data": "foobar",
"error": false,
"type": "log"
}
]
`;

exports[`test BufferReporter.step 1`] = `
Array [
Object {
"data": Object {
"current": 1,
"message": "foobar",
"total": 5
},
"error": false,
"type": "step"
}
]
`;

exports[`test BufferReporter.success 1`] = `
Array [
Object {
"data": "foobar",
"error": false,
"type": "success"
}
]
`;

exports[`test BufferReporter.warn 1`] = `
Array [
Object {
"data": "foobar",
"error": true,
"type": "warning"
}
]
`;
107 changes: 107 additions & 0 deletions __tests__/reporters/__snapshots__/console.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
exports[`test ConsoleReporter.activity 1`] = `
Object {
"stderr": "⠁ ",
"stdout": ""
}
`;

exports[`test ConsoleReporter.command 1`] = `
Object {
"stderr": "",
"stdout": "$ foobar"
}
`;

exports[`test ConsoleReporter.error 1`] = `
Object {
"stderr": "error foobar",
"stdout": ""
}
`;

exports[`test ConsoleReporter.footer 1`] = `
Object {
"stderr": "",
"stdout": "✨ Done in 0.00s."
}
`;

exports[`test ConsoleReporter.footer 2`] = `
Object {
"stderr": "",
"stdout": "✨ Done in 0.00s. Peak memory usage 0.00MB."
}
`;

exports[`test ConsoleReporter.header 1`] = `
Object {
"stderr": "",
"stdout": "kpm foobar v0.0.0"
}
`;

exports[`test ConsoleReporter.info 1`] = `
Object {
"stderr": "",
"stdout": "info foobar"
}
`;

exports[`test ConsoleReporter.log 1`] = `
Object {
"stderr": "",
"stdout": "foobar"
}
`;

exports[`test ConsoleReporter.progress 1`] = `
Object {
"stderr": "░░ 0/2█░ 1/2",
"stdout": ""
}
`;

exports[`test ConsoleReporter.progress 2`] = `
Object {
"stderr": "",
"stdout": ""
}
`;

exports[`test ConsoleReporter.progress 3`] = `
Object {
"stderr": "",
"stdout": ""
}
`;

exports[`test ConsoleReporter.select 1`] = `
Object {
"stderr": "",
"stdout": "info Ayo
 1) foo
 2) bar
Select one?: 1"
}
`;
exports[`test ConsoleReporter.step 1`] = `
Object {
"stderr": "",
"stdout": "[1/5] foboar..."
}
`;
exports[`test ConsoleReporter.success 1`] = `
Object {
"stderr": "",
"stdout": "success foobar"
}
`;
exports[`test ConsoleReporter.warn 1`] = `
Object {
"stderr": "warning foobar",
"stdout": ""
}
`;
52 changes: 8 additions & 44 deletions __tests__/reporters/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,83 +17,47 @@ let getBuff = build(BufferReporter, (data, reporter: any): Array<Object> => repo
test('BufferReporter.finished', async () => {
expect(await getBuff((r) => {
r.footer(false);
})).toEqual([{
type: 'finished',
data: 0,
error: false,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.step', async () => {
expect(await getBuff((r) => {
r.step(1, 5, 'foobar');
})).toEqual([{
type: 'step',
data: {
current: 1,
total: 5,
message: 'foobar',
},
error: false,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.log', async () => {
expect(await getBuff((r) => {
r.log('foobar');
})).toEqual([{
type: 'log',
data: 'foobar',
error: false,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.success', async () => {
expect(await getBuff((r) => {
r.success('foobar');
})).toEqual([{
type: 'success',
data: 'foobar',
error: false,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.error', async () => {
expect(await getBuff((r) => {
r.error('foobar');
})).toEqual([{
type: 'error',
data: 'foobar',
error: true,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.info', async () => {
expect(await getBuff((r) => {
r.info('foobar');
})).toEqual([{
type: 'info',
data: 'foobar',
error: false,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.command', async () => {
expect(await getBuff((r) => {
r.command('foobar');
})).toEqual([{
type: 'command',
data: 'foobar',
error: false,
}]);
})).toMatchSnapshot();
});

test('BufferReporter.warn', async () => {
expect(await getBuff((r) => {
r.warn('foobar');
})).toEqual([{
type: 'warning',
data: 'foobar',
error: true,
}]);
})).toMatchSnapshot();
});
Loading

0 comments on commit 06853a7

Please sign in to comment.