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

Decaffeinate featured spec #73

Merged
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
55 changes: 0 additions & 55 deletions spec/featured-spec.coffee

This file was deleted.

70 changes: 36 additions & 34 deletions spec/featured-spec.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,65 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
const path = require('path');
const express = require('express');
const http = require('http');
const apm = require('../lib/apm-cli');

describe('apm featured', function() {
describe('apm featured', () => {
let server = null;

beforeEach(function() {
beforeEach(() => {
silenceOutput();
spyOnToken();

const app = express();
app.get('/packages/featured', (request, response) => response.sendFile(path.join(__dirname, 'fixtures', 'packages.json')));
app.get('/themes/featured', (request, response) => response.sendFile(path.join(__dirname, 'fixtures', 'themes.json')));

app.get('/packages/featured', (request, response) => {
response.sendFile(path.join(__dirname, 'fixtures', 'packages.json'));
});

app.get('/themes/featured', (request, response) => {
response.sendFile(path.join(__dirname, 'fixtures', 'themes.json'));
});

server = http.createServer(app);

let live = false;
server.listen(3000, '127.0.0.1', function() {
process.env.ATOM_API_URL = "http://localhost:3000";
return live = true;

server.listen(3000, '127.0.0.1', () => {
process.env.ATOM_API_URL = 'http://localhost:3000';
live = true;
});
return waitsFor(() => live);

waitsFor(() => live);
});

afterEach(function() {
afterEach(() => {
let done = false;
server.close(() => done = true);
return waitsFor(() => done);
server.close(() => {
done = true;
});
waitsFor(() => done);
});

it('lists the featured packages and themes', function() {
it('lists the featured packages and themes', () => {
const callback = jasmine.createSpy('callback');
apm.run(['featured'], callback);

waitsFor('waiting for command to complete', () => callback.callCount > 0);

return runs(function() {
runs(() => {
expect(console.log).toHaveBeenCalled();
expect(console.log.argsForCall[1][0]).toContain('beverly-hills');
expect(console.log.argsForCall[2][0]).toContain('multi-version');
return expect(console.log.argsForCall[3][0]).toContain('duckblur');
expect(console.log.argsForCall[3][0]).toContain('duckblur');
});
});

return describe('when the theme flag is specified', () => it("lists the featured themes", function() {
const callback = jasmine.createSpy('callback');
apm.run(['featured', '--themes'], callback);

waitsFor('waiting for command to complete', () => callback.callCount > 0);

return runs(function() {
expect(console.log).toHaveBeenCalled();
expect(console.log.argsForCall[1][0]).toContain('duckblur');
return expect(console.log.argsForCall[2][0]).toBeUndefined();
describe('when the theme flag is specified', () => {
it('lists the featured themes', () => {
const callback = jasmine.createSpy('callback');
apm.run(['featured', '--themes'], callback);
waitsFor('waiting for command to complete', () => callback.callCount > 0);
runs(() => {
expect(console.log).toHaveBeenCalled();
expect(console.log.argsForCall[1][0]).toContain('duckblur');
expect(console.log.argsForCall[2][0]).toBeUndefined();
});
});
}));
});
});