Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove co usage #6124

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"broccoli-test-helper": "^2.0.0",
"broccoli-uglify-sourcemap": "^3.0.0",
"chalk": "^2.4.1",
"co": "^4.6.0",
"command-line-args": "^5.1.1",
"common-tags": "^1.8.0",
"debug": "^4.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const BroccoliTestHelper = require('broccoli-test-helper');
const co = require('co');
const Babel = require('broccoli-babel-transpiler');
const chai = require('ember-cli-blueprint-test-helpers/chai');
const stripIndent = require('common-tags').stripIndent;
Expand All @@ -19,71 +18,60 @@ describe('Unit: babel-plugin-remove-filtered-imports', function() {
let plugins, pluginOptions;
let input, output;

function transform(code) {
return co.wrap(function*() {
input.write({ 'test.js': code });
let babel = new Babel(input.path(), {
plugins,
});
async function transform(code) {
input.write({ 'test.js': code });
let babel = new Babel(input.path(), {
plugins,
});

output = createBuilder(babel);
output = createBuilder(babel);

yield output.build();
await output.build();

const transpiled = output.read();
const transpiled = output.read();

return stripNewlines(transpiled['test.js']);
})();
return stripNewlines(transpiled['test.js']);
}

beforeEach(
co.wrap(function*() {
pluginOptions = {};
beforeEach(async function() {
pluginOptions = {};

plugins = [[StripFilteredImports, pluginOptions]];
plugins = [[StripFilteredImports, pluginOptions]];

input = yield createTempDir();
})
);
input = await createTempDir();
});

afterEach(
co.wrap(function*() {
if (input) {
yield input.dispose();
}
if (output) {
yield output.dispose();
}
afterEach(async function() {
if (input) {
await input.dispose();
}
if (output) {
await output.dispose();
}

input = output = undefined;
})
);
input = output = undefined;
});

it('Returns a plugin', function() {
let plugin = StripFilteredImports();

expect(plugin).to.be.ok;
});

it(
'Does not alter a file if no imports are meant to be filtered',
co.wrap(function*() {
const input = stripIndent`
it('Does not alter a file if no imports are meant to be filtered', async function() {
const input = stripIndent`
import Foo from 'bar';
import { baz } from 'none';
import * as drinks from 'drinks';
import 'bem';
`;
const result = yield transform(input);
const result = await transform(input);

expect(result).to.equal(stripNewlines(input));
})
);
expect(result).to.equal(stripNewlines(input));
});

it(
'Properly strips desired imports and specifiers',
co.wrap(function*() {
const input = stripIndent`
it('Properly strips desired imports and specifiers', async function() {
const input = stripIndent`
import Foo from 'bar';
import { bit } from 'wow';
import { baz, bell } from 'none';
Expand All @@ -95,24 +83,23 @@ describe('Unit: babel-plugin-remove-filtered-imports', function() {
import 'bell';
`;

pluginOptions.none = ['baz'];
pluginOptions.bar = true;
pluginOptions.drinks = '*';
pluginOptions.wow = ['bit'];
pluginOptions.bem = ['biz'];
pluginOptions.bosh = '*';
pluginOptions.dranks = ['bex'];
pluginOptions.bell = true;
pluginOptions.none = ['baz'];
pluginOptions.bar = true;
pluginOptions.drinks = '*';
pluginOptions.wow = ['bit'];
pluginOptions.bem = ['biz'];
pluginOptions.bosh = '*';
pluginOptions.dranks = ['bex'];
pluginOptions.bell = true;

const expectedOutput = stripNewlines(stripIndent`
const expectedOutput = stripNewlines(stripIndent`
import { bell } from 'none';
import { foo } from 'happy';
import * as dranks from 'dranks';
import 'bem';
`);
const result = yield transform(input);
const result = await transform(input);

expect(result).to.equal(expectedOutput);
})
);
expect(result).to.equal(expectedOutput);
});
});