2020-01-15 19:41:47 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2019-2020 Balena Ltd.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-11-07 10:02:44 +00:00
|
|
|
import { expect } from 'chai';
|
2020-01-15 19:41:47 +00:00
|
|
|
|
2019-12-05 08:57:47 +00:00
|
|
|
import { BalenaAPIMock } from '../../balena-api-mock';
|
2019-11-14 09:53:38 +00:00
|
|
|
import { cleanOutput, runCommand } from '../../helpers';
|
2019-11-07 10:02:44 +00:00
|
|
|
|
2020-06-15 22:53:07 +00:00
|
|
|
describe('balena devices supported', function () {
|
2019-12-05 08:57:47 +00:00
|
|
|
let api: BalenaAPIMock;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
api = new BalenaAPIMock();
|
2020-07-09 14:39:33 +00:00
|
|
|
api.expectGetWhoAmI({ optional: true });
|
|
|
|
api.expectGetMixpanel({ optional: true });
|
2019-12-05 08:57:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
// Check all expected api calls have been made and clean up.
|
|
|
|
api.done();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should print help text with the -h flag', async () => {
|
|
|
|
const { out, err } = await runCommand('devices supported -h');
|
|
|
|
|
2019-12-26 22:59:44 +00:00
|
|
|
expect(cleanOutput(out)).to.contain('$ balena devices supported');
|
2019-12-05 08:57:47 +00:00
|
|
|
|
|
|
|
expect(err).to.eql([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should list currently supported devices, with correct filtering', async () => {
|
2020-01-15 19:41:47 +00:00
|
|
|
api.expectGetDeviceTypes();
|
2019-12-05 08:57:47 +00:00
|
|
|
|
2019-11-07 10:02:44 +00:00
|
|
|
const { out, err } = await runCommand('devices supported');
|
|
|
|
|
|
|
|
const lines = cleanOutput(out);
|
|
|
|
|
2020-12-07 13:58:23 +00:00
|
|
|
expect(lines[0].replace(/ +/g, ' ')).to.equal('SLUG ALIASES ARCH NAME');
|
2019-11-07 10:02:44 +00:00
|
|
|
expect(lines).to.have.lengthOf.at.least(2);
|
|
|
|
|
2019-12-05 08:57:47 +00:00
|
|
|
// Discontinued devices should be filtered out from results
|
2020-06-15 22:53:07 +00:00
|
|
|
expect(lines.some((l) => l.includes('DISCONTINUED'))).to.be.false;
|
2019-11-07 10:02:44 +00:00
|
|
|
|
2020-07-15 16:05:39 +00:00
|
|
|
// Experimental devices should be listed as new
|
2020-06-15 22:53:07 +00:00
|
|
|
expect(lines.some((l) => l.includes('EXPERIMENTAL'))).to.be.false;
|
|
|
|
expect(lines.some((l) => l.includes('NEW'))).to.be.true;
|
2019-11-07 10:02:44 +00:00
|
|
|
|
2019-12-05 08:57:47 +00:00
|
|
|
expect(err).to.eql([]);
|
2019-11-07 10:02:44 +00:00
|
|
|
});
|
|
|
|
});
|