Skip to content

Commit

Permalink
tests: fix warnings during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Sep 4, 2018
1 parent 5ecf142 commit 583d945
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
45 changes: 36 additions & 9 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should run prettier', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

const code = 'var foo=0;var test="hello world";';
const result = instance.transformBundle(code);
Expand All @@ -52,7 +54,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should run prettier with sourceMap (camelcase with rollup < 0.48)', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

instance.options({
sourceMap: true,
Expand All @@ -79,7 +83,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should run prettier with sourcemap (lowercase with rollup >= 0.48)', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

instance.options({
sourcemap: true,
Expand All @@ -106,7 +112,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should run prettier with sourcemap in output options', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

// The input options may not contain `sourcemap` entry with rollup >= 0.53.
instance.options({});
Expand Down Expand Up @@ -134,7 +142,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should run prettier with sourcemap in output options (camelcase format)', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

// The input options may not contain `sourcemap` entry with rollup >= 0.53.
instance.options({});
Expand Down Expand Up @@ -162,7 +172,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should run prettier with sourcemap disabled in output options', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

// The input options may not contain `sourcemap` entry with rollup >= 0.53.
instance.options({});
Expand All @@ -184,6 +196,7 @@ describe('rollup-plugin-prettier', () => {

it('should run prettier with options', () => {
const options = {
parser: 'babylon',
singleQuote: true,
};

Expand All @@ -203,7 +216,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should remove unnecessary spaces', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

instance.options({
sourceMap: false,
Expand All @@ -219,7 +234,9 @@ describe('rollup-plugin-prettier', () => {
});

it('should add and remove characters', () => {
const instance = plugin();
const instance = plugin({
parser: 'babylon',
});

instance.options({
sourceMap: false,
Expand All @@ -236,6 +253,7 @@ describe('rollup-plugin-prettier', () => {

it('should avoid side effect and do not modify plugin options', () => {
const options = {
parser: 'babylon',
sourceMap: false,
};

Expand All @@ -245,12 +263,14 @@ describe('rollup-plugin-prettier', () => {

// It should not have been touched.
expect(options).toEqual({
parser: 'babylon',
sourceMap: false,
});
});

it('should run prettier without sourcemap options', () => {
const options = {
parser: 'babylon',
sourceMap: false,
};

Expand All @@ -261,14 +281,19 @@ describe('rollup-plugin-prettier', () => {
instance.options({});
instance.transformBundle(code);

expect(prettier.format).toHaveBeenCalledWith(code, undefined);
expect(prettier.format).toHaveBeenCalledWith(code, {
parser: 'babylon',
});

expect(options).toEqual({
parser: 'babylon',
sourceMap: false,
});
});

it('should run prettier without sourcemap options and custom other options', () => {
const options = {
parser: 'babylon',
sourceMap: false,
singleQuote: true,
};
Expand All @@ -281,10 +306,12 @@ describe('rollup-plugin-prettier', () => {
instance.transformBundle(code);

expect(prettier.format).toHaveBeenCalledWith(code, {
parser: 'babylon',
singleQuote: true,
});

expect(options).toEqual({
parser: 'babylon',
sourceMap: false,
singleQuote: true,
});
Expand Down
14 changes: 11 additions & 3 deletions test/it/it.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ describe('rollup-plugin-prettier', () => {
},

plugins: [
prettier(),
prettier({
parser: 'babylon',
}),
],
};

Expand Down Expand Up @@ -96,7 +98,9 @@ describe('rollup-plugin-prettier', () => {
},

plugins: [
prettier(),
prettier({
parser: 'babylon',
}),
],
};

Expand Down Expand Up @@ -132,7 +136,9 @@ describe('rollup-plugin-prettier', () => {
],

plugins: [
prettier(),
prettier({
parser: 'babylon',
}),
],
};

Expand Down Expand Up @@ -172,6 +178,7 @@ describe('rollup-plugin-prettier', () => {

plugins: [
prettier({
parser: 'babylon',
sourcemap: true,
}),
],
Expand Down Expand Up @@ -209,6 +216,7 @@ describe('rollup-plugin-prettier', () => {

plugins: [
prettier({
parser: 'babylon',
sourceMap: true,
}),
],
Expand Down

0 comments on commit 583d945

Please sign in to comment.