2020-01-15 19:41:47 +00:00
|
|
|
/**
|
|
|
|
* @license
|
2021-05-14 23:58:15 +00:00
|
|
|
* Copyright 2019-2021 Balena Ltd.
|
2020-01-15 19:41:47 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2021-06-25 23:42:07 +00:00
|
|
|
import { BalenaAPIMock } from '../../nock/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 });
|
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
|
|
|
|
2021-12-19 22:40:26 +00:00
|
|
|
const { out, err } = await runCommand('devices supported');
|
2019-11-07 10:02:44 +00:00
|
|
|
|
2021-05-14 23:58:15 +00:00
|
|
|
const lines = cleanOutput(out, true);
|
2019-11-07 10:02:44 +00:00
|
|
|
|
2021-12-19 22:40:26 +00:00
|
|
|
expect(lines[0]).to.equal('SLUG ALIASES ARCH NAME');
|
2019-11-07 10:02:44 +00:00
|
|
|
expect(lines).to.have.lengthOf.at.least(2);
|
2021-12-19 22:40:26 +00:00
|
|
|
expect(lines).to.contain('intel-nuc nuc amd64 Intel NUC');
|
2021-05-14 23:58:15 +00:00
|
|
|
expect(lines).to.contain(
|
2022-10-17 14:01:33 +00:00
|
|
|
'odroid-xu4 odroid-u3+, odroid-ux3 armv7hf ODROID-XU4',
|
2021-05-14 23:58:15 +00:00
|
|
|
);
|
2019-12-05 08:57:47 +00:00
|
|
|
expect(err).to.eql([]);
|
2019-11-07 10:02:44 +00:00
|
|
|
});
|
|
|
|
});
|